IndexError: tuple index out of range

0 votes

Hi Guys,

I have one Machine Learning model, which detects my face. It detects my face but sometimes I am getting this below error.

IndexError                                Traceback (most recent call last)
<ipython-input-2-41b72326245f> in <module>
----> 1 y = x[0][0]
IndexError: tuple index out of range
Apr 15 in Machine Learning by akhtar
• 10,580 points
310 views

1 answer to this question.

0 votes

Hi@akhtar,

I don't know your use cases. But you may got this error when your tuple don't have any value. For an Example.

>>>x = ()
>>>y = x[0]
IndexError                                Traceback (most recent call last)
<ipython-input-3-5679abac6acb> in <module>
      1 x = ()
----> 2 y = x[0]
IndexError: tuple index out of range

Here I am trying to assign an empty tuple to y. So I am getting this error. But You can avoid this error using if else condition.

if len(x)==0:
    pass
else:
    print('your code')

Hope this will help you.

answered Apr 15 by MD
• 23,050 points

Related Questions In Machine Learning

0 votes
1 answer

Are there different types of reinforcements?

There are two types of reinforcements - ...READ MORE

answered May 8, 2019 in Machine Learning by Mishra
76 views
0 votes
1 answer

Real world applications of Machine Learning

Few real-world applications of machine learning are  Have ...READ MORE

answered May 9, 2019 in Machine Learning by Jinu
106 views
0 votes
1 answer

What are different types of regressions?

There are three types of regressions: Linear regression: Linear ...READ MORE

answered May 9, 2019 in Machine Learning by Jinu
242 views
0 votes
1 answer

Different types of Logistic Regression

There are three main types of logistic ...READ MORE

answered May 13, 2019 in Machine Learning by Nikhil
3,375 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 947 views
0 votes
0 answers
+4 votes
6 answers
0 votes
1 answer

not able to see all columns and rows of a pandas DataFrame?

Hi@akhtar, Your data set contains lots of rows ...READ MORE

answered Apr 8 in Machine Learning by MD
• 23,050 points
75 views
0 votes
3 answers