Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCaitlin Scouler
7,082 Points'IndexError: too many indices for array'
Hi guys,
I am following the video but I get an error when inputting:
study_minutes[(1, 0)]
I get:
'IndexError: too many indices for array'
Am I doing something wrong?
3 Answers
Ryan Haynes
42 PointsIn python, if you're referring to a 2D array, you'd approach it as this: study_minutes[1][1] = 360 It's a little annoying sometimes, but for each dimension you add, you just add another [] at the end.
Hopefully this helps.
Dorde Krstic
1,775 PointsI think it should be:
study_minutes[1, 0]
He explained that 1, 0 in [1, 0] is actually a tuple (1, 0) but you don't need to write it in the code.
Caitlin Scouler
7,082 PointsThanks Dorde, but I still get the same error :(
Caitlin Scouler
7,082 PointsI just ran the Notebook from the video download and still get an error:
study_minutes[1, 1] = 360
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-0fb6eb80a6ee> in <module>
----> 1 study_minutes[1, 1] = 360
NameError: name 'study_minutes' is not defined
Any idea why guys?
Connor Nally
22,401 PointsI had similar problems, I think it's because we're running the code out of order, or you've closed and opened the page. Try 'Kernel: Restart & Run All'. He goes through the error in the next video. :)