FAQ: Introduction to Lists in Python - Growing a List: Plus (+)

This community-built FAQ covers the “Growing a List: Plus (+)” exercise from the lesson “Introduction to Lists in Python”.

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

Visualize Data with Python
Data Scientist
Analyze Data with Python
Computer Science
Analyze Financial Data with Python
Build Chatbots with Python
Build Python Web Apps with Flask
Data Analyst

Learn Python 3
CS101 Livestream Series

FAQs on the exercise Growing a List: Plus (+)

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

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

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

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

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

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!

So in the session it gives the example for adding one item to a list by using this code:

my_list + [4]

but when I did that to try it out it didn’t work. I had to type:

my_list = my_list + [4]

and then it would print the list + 4 the other way didn’t throw a code but it didn’t add 4 to the end of my list. Is it not suppose to?

Ok to add, I tried it in terminal, since we set up IPython and I wrote this code:

list = [1, 2, 3, 4, 5]
print(list)

list + [4]
print(list)

the first print statement printed “[1, 2, 3, 4, 5]”
the second printed “[1, 2, 3, 4, 5, 4]”

So it does work that way! However it doesn’t print that way in the codecademy playground.

4 Likes

Hi, I’m having trouble with running the code in this lesson. It runs but the exercise still says I’ve done it incorrectly despite the “hint” indicating that I have done it correctly. Is there an issue with Codecademy Pro or am I missing something? My code is:

orders = [“daisy”, “buttercup”, “snapdragon”, “gardenia”, “lily”]

Create new orders here:

new_orders = orders + [“lilac”, “iris”]

print(new_orders)

1 Like

Don’t worry. I figured it out. I didn’t realise the exercise was wanting me to create two separate lists.

2 Likes

Yeah, this one threw me for a little while too - for anyone else confused, this guy is right :slight_smile:

I’m still confused. I might need a more explicit answer, please. Thank you.

UPDATE: figured it out. Just declare a new list called new_orders with lilac and iris as list items.

Hi, I have a question. I get that by using Plus we add something at the end of the list, but is there a way to ad something in another place, for example at the beginning or in the middle of it?

list = list + [4]
list += [4]
.append[4]
.extend[4, 5, 6]

list + [4] doesn’t work

1 Like

i am still very confused. I don’t understand why Codecademy throws an error when trying to use the same example list + [4].

how to get the output of lists without the [ ] brackets? in the terminal.

1 Like

Hi, what does + [4] do exactly? why is it there and what does it do?

If you have a list [2 , 3]
and you do new_list = [2, 3] + [4]
then new_list would be [2, 3, 4]

here’s another one:

alpha = ['a', 'b', 'c']
beta = ['d', 'e']
alphabet = alpha + beta

alphabet would now be ['a', 'b', 'c', 'd', 'e']

2 Likes

These instructions are ambiguous, though:
“Create a list called new_orders that contains our new orders”

It will accept

new_orders = orders + ["lilac", "iris"]

for step 1, which it should because it adheres to the instructions.
But then on step 2, it does not accept

orders_combined = orders + new_orders

It should be specified that what they actually want in step 1 is a list that contains only our new orders

2 Likes

I had this same issue, thanks. It’s not clear enough!

I have the same question, how would you print the list less brackets and quotes?

for example:

print(“my face”)

The terminal will out put: my face

but if you store the text as a list:

face = [“my face”]

and then print face

print(face)

the terminal would output [‘my face’]

I’m curious if you can do different lists or set python to print with different text or formatting?

I’m not sure why you don’t need parentheses around orders + new_orders when you type:

new_orders = ['lilac', 'iris']
orders_combined = orders + new_orders

Why does allow me to print that without error? I thought it would have needed to be (orders + new_orders)?

oof. yeah this one’s very confusing

I tried orders += new_orders, and then printed orders and got [‘daisy’, ‘buttercup’, ‘snapdragon’, ‘gardenia’, ‘lily’, ‘lilac’, ‘iris’]. I get the same print out when I use the extend method. It also updates the orders variable without creating the new variable, new_orders, by using orders += [‘lilac’, ‘iris’]

@py4410902729 someone else in another FAQ had mentioned that the +=operator for lists functions exactly like .extend() method - so the same output would be expected. This method is the extension of the + operator that we learn on this exercise in that if you are not looking to create a new variable or list and just looking to update the existing one.

@gr3y_ht @krushnakantchavan559
The square brackets is what distinguish a list of objects versus just a single object. In the example you give, “my face” is just a single string object. List allows you to have multiple different elements stored with indices so you can recall them later.

You can always print individual objects within a list by doing print(list(i)), where i is the position of the object within the list with the first object having i = 0, second object with i = 1 and so on.

For example,

broken_prices = [5, 3, 4, 5, 4] + [4] print(broken_prices[1])
1 Like

When using (+), can you add multiple lists?

EX.
list_1 = [ 1, 2, 3, 4, 5]
list_2 = [ 6, 7, 8, 9, 10]
list_3 = [ 11, 12, 13, 14, 15]

full_list = list_1 + list_2 + list_3