Post

PythonPython

r
rushi chowdary

Posted on 4th March 2024|98 views

0
votes

Python Too Many Indices For Array

How to resolve the error “too many indices for an array”?

I am getting an error called too many indices for an array here is my code 

import numpy as np

y = np.array([311,116,8,118,007,185,13])

print(y[0,3])  

 

Answers
P
chris bons

Posted on 4th March 2024

The only problem is you have declared a single dimension array using a numpy library, but in your code, you are trying to print it as a two-dimensional array better try this:

import numpy as np

y = np.array([311,116,8,118,007,185,13])

print(y[0])  

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos