FAQ: Introduction to NumPy - Two-Dimensional Arrays

This community-built FAQ covers the “Two-Dimensional Arrays” exercise from the lesson “Introduction to NumPy”.

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

Data Science

Introduction to Statistics with NumPy

FAQs on the exercise Two-Dimensional Arrays

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!

Why doesn’t this code work here:

coin_toss_again = np.array([[coin_toss],[0,0,1,1,1]])

1 Like

If you remove the brackets around ‘coin_toss’ it will work. ‘coin_toss’ does not need brackets as it is already an array/list.

Why does it matter that the results of ‘coin_toss’ goes first in the new array? I was stumped on why my code didn’t work and the solution was that it was because I had the result of ‘coin_toss’ listed as the 2nd part of the array.


When using np.array to create a list of lists and printing the result afterwards, do I need to insert the list() function within the print statement?

new_array = np.array([[92, 94, 88, 91, 87], [79, 100, 86, 93, 91], [87, 85, 72, 90, 92]])

print(new_array) OR print(list(new_array)) — I do not understand when list() needs to be in the print statement…

Grateful for any advice, thanks!

You can create a python list in two ways;

list( <some data> )


[ <some data> ]

They are interchangeable, and you should get the same result.

So you need to retype the first array and the second to append the new list? How is this easier than just using a list and .append as opposed to an array?

I don’t know what is wrong with my code.