Creating iterate over an enumerated list

I have a list of 8 organisms, they are assigned a number starting with zero. some of them are animals and some are not. this is the instructions for the activity, i’m unsure what coding to use.

We can “iterate” (AKA loop) over an enumerated list. An example can be found in the following code. Alter the code to only print() one of the following statements for each organism.

organism is an animal.

organism is not an animal.

Hints:

  • **Watch the [indentation]
  • You will need to utilize an [if statement]
  • To [access a specific item from a list]we can use what is called an index. In Python, all indexing starts at 0!

[148]:

Enumerating over the list of organisms and printing information​/

for i, organism in enumerate(organisms):
print('Organism ', i) # print organism index
print(organism) # print organism

Please read the pinned thread in order to understand how to post code with proper formatting, so that we can properly understand the current state of the code. Then carefully think about the problem and use your own words to ask a question, instead of just copying and pasting from a homework assignment. The assignment tells us many things that any experiences programmer will already know, and it tells us a description of a problem; but it does not tell us where you are having difficulty, or why.

2 Likes