+ 1

I wrote following code but it gives syntaxError in "def __len__(self) . Can anyone explain to me,please. why?

https://code.sololearn.com/cD6XZUrZRWcF/?ref=app.

7th Jul 2018, 9:03 AM
Saeed Mozaffari
Saeed Mozaffari - avatar
5 odpowiedzi
+ 4
I think there is also an error in line 33, it should be like this? int_list = IntList ([2, 1, 4, 3, 5, 6, 7, 8])
7th Jul 2018, 11:10 AM
Paul
Paul - avatar
+ 2
I got your mistake, you can checkout this code https://code.sololearn.com/c9jI1kHlM4d9/?ref=app
7th Jul 2018, 10:42 AM
Pulkit Kamboj
Pulkit Kamboj - avatar
+ 1
the only mistake you had done was you were missing ']' in line 27
7th Jul 2018, 10:49 AM
Pulkit Kamboj
Pulkit Kamboj - avatar
+ 1
Your "int_list" is a TUPLE that contain a list. Now, if your try to access at third member of "int_list" you will get an Index out of range error because the "int_list" TUPLE has ONE item only.... If you want access to 3rd item of first tuple item you can do : int_list[0][2] int_list[0] access to tuple (with one element only) and [2] access to 3rd item of this element
7th Jul 2018, 10:53 AM
KrOW
KrOW - avatar
0
Pulkit Kamboj I checked out your modification but it says in line 31 it's out of range. Yeah i got it finally . Thank you.
7th Jul 2018, 11:55 AM
Saeed Mozaffari
Saeed Mozaffari - avatar