List Iteration in Python
Level 254 keystrokes
This loops through a list of fruits and prints each one. The for loop iterates over each element in the list.
Python code
# Create a list containing two fruit names as strings1fruits = ["apple", "banana"]# for loop iterates through each item in the list# f is a variable that holds the current item2for f in fruits: # First iteration: f = "apple" # Second iteration: f = "banana"3 print(f)Output
apple banana
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
"× 4,× 1:× 1(× 1)× 1[× 1]× 1=× 1