FAQ: Working with Lists in Python - Selecting List Elements I

This community-built FAQ covers the “Selecting List Elements I” exercise from the lesson “Working with Lists in Python”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science
Data Science

FAQs on the exercise Selecting List Elements I

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

In the example given in this lesson we are given the following list:

calls = ['Ali', 'Bob', 'Cam', 'Doug', 'Ellie']

We are then told that when we use print(calls[2]) that 'Cam' is printed. However, when I ran this code in both the Codecademy editor and console, as well as my Python 3.9 app, simply Cam was printed instead.

Why is this?

Hello Malachi,

I am not completely sure about this, but my guess is that what they used in the explanation is not an actual code, but more of an example.

Please see that in their explanation the command print is preceded by >>>. When I try to execute such a command, I receive a Synthax Error. Try yourself and you will see!

Even if I am wrong and there is another reason for this, I think that if the Codeacademy editor and console, as well as your Python show Cam and not 'Cam', so this is how it should be and there is nothing to worry about :slight_smile:

Hope it helps you a little bit!

1 Like

Hi @malachigruenhagen834 and @array0078619254 !

You’re correct in that the single quotes around Cam don’t actually show up. They might have been put in there to demonstrate that a string is being printed out since Cam is a string.

As for the >>>, what you’re actually seeing is the Python shell being used. >>> is the prompt for the Python shell, which shows the user that the computer is ready to perform a command. It’s not meant to be used in a program that you write in a code editor. In this case, the command print(calls[2]) was entered and the output was printed, Cam. You can find the shell online here, but it’s also installed on your computer when you install Python.