155k views
22 votes
Write one for loop to print out each element of the list several things. then write another for loop

User MungoRae
by
5.0k points

1 Answer

12 votes

Question:

Write one for loop to print out each element of the list several_things. Then, write another for loop to print out the TYPE of each element of the list several_things.

Answer:

The solution in python is as follows:

for element in several_things:

print(element)

for element in several_things:

print(type(element))

Step-by-step explanation:

The solution assumes that the list several_things has already been initialized.

So, the rest of the code is explained as follows:

This line iterates through the list, several_things

for element in several_things:

This line prints each element

print(element)

This line iterates through the list, several_things for the second time

for element in several_things:

This line prints the type of each element

print(type(element))

User Leonard AB
by
5.2k points