📜  python 如何在列表中循环 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:56.208000             🧑  作者: Mango

代码示例3
fruits = ["apple", "banana", "strawberry"]

for fruit in fruits:
  print(fruit)
  #This "for fruit in fruits" gets every item in order from that list and does something with it
  #for example I print the fruit
  #note: This loop will only end when there aren't any items left in the list
           #example: After strawberry there isn't anything else soo the loop ends
#output: apple
         #banana
           #stawberry