Poone Kricanakarin Poone Kricanakarin - 26 days ago 8
Python Question

Python Chapter 7 Lists and Tuples

Here is the question. Assume names references a list. Write a for loop that displays each element of the list. I don't know how to do this, can you please help me walk me through it? This is what I did. But this one is not right.

for element in the_list:
print(element)

Answer

You'll need to define the_list first.

Try this code, for example:

the_list = ["Jenny", "Timmy", "Jackson", "Lucy"]
for element in the_list: 
  print(element)
Comments