192k views
4 votes
Animals = ['aardvark', 'anteater', 'antelope', 'albert'] >>>animals[9999] Help, my teacher wants to me to explain what the output is and why for this python code, but I really don't know what to do for the second part. If we were just printing the "animals = ['aardvark', 'anteater', 'antelope', 'albert']" part it would be easy. However, I don't know about the >>>animals[9999] part. Apparently, the >>> is supposed to mean call function. Could someone explain what output would be and why?

User Shavana
by
6.9k points

1 Answer

4 votes

Answer:

index out of range error

Step-by-step explanation:

Not really. >>>animals[9999] implies that you need to type "animals[9999]" into the shell.

When you type animals[9999], you are trying access the 9998th element of the animals. Since there is not 9998th element in the list, you will get an index out of range error.

But let's say you want to access the first element in the list, then you would type animals[0] and it would print "aardvark".

User Jimit Patel
by
6.8k points