+ 1

Need help.

list= [0, 1.00794, 4.002602, 6.941, 9.012182, 10.811, 12.0107, 14.0067, 15.9994, 18.84032, 20.1797, 22.989770, 24.3050, 26.9815 38, 28.0855, 30.973761, 32.065, 35.153, 39.948, 39.0983, 40.078 ] print (list [2]) But I got error. Please tell me my mistakes. In phyton

7th Feb 2018, 1:36 AM
Mahmudul Hasan Fahim
Mahmudul Hasan Fahim - avatar
9 Answers
+ 4
Oh, I just found the problem. Okay, to start, completely disregard my previous comment, it was totally false (they can have multiple different data types stored within them). If you look at the number beside 26.9815, it has no comma separating it (the number should be 38). If you either get rid of the whitespace between the 2 values or add a comma between them, it should work.
7th Feb 2018, 1:48 AM
Faisal
Faisal - avatar
+ 2
also, shouldn't name your list "list"
7th Feb 2018, 1:56 AM
LordHill
LordHill - avatar
+ 1
Thanks Bro
7th Feb 2018, 1:40 AM
Mahmudul Hasan Fahim
Mahmudul Hasan Fahim - avatar
+ 1
But I have same error massage
7th Feb 2018, 1:43 AM
Mahmudul Hasan Fahim
Mahmudul Hasan Fahim - avatar
+ 1
Yeah, after testing it I too am still getting an error.
7th Feb 2018, 1:45 AM
Faisal
Faisal - avatar
+ 1
đŸ˜„đŸ˜„đŸ˜„
7th Feb 2018, 1:46 AM
Mahmudul Hasan Fahim
Mahmudul Hasan Fahim - avatar
0
oops... 🙄🙄🙄
7th Feb 2018, 1:51 AM
Mahmudul Hasan Fahim
Mahmudul Hasan Fahim - avatar
0
Yup...
7th Feb 2018, 1:58 AM
Mahmudul Hasan Fahim
Mahmudul Hasan Fahim - avatar
- 3
In Python, lists must only contain one specific data type. Because you have 2 data types (int and float), the list becomes obsolete and therefore results in an error trying to use it. What I would suggest is to change the first element to 0.0, so it follows the trend of floats and keeps the list the same throughout.
7th Feb 2018, 1:39 AM
Faisal
Faisal - avatar