+ 1

Lists

list = [ 42, 55, 67] print(list[ 2 ]) Explain me this Question?

15th Aug 2020, 9:17 AM
Jash Sampat
5 Respuestas
+ 1
Hi, 3rd entry of list is asked
15th Aug 2020, 9:21 AM
Oma Falk
Oma Falk - avatar
0
A list is a construct tha allwos the storage of mutiple elements. The syntax goes as follows: "the name of your list in this case just "list" = [ ] or [element nr.1,element nr.2 ... Etc] You can instanciate a list empty or pre filled deppending on the example above. You cann acces elements inside a list by calling the name of the list and nr of the possition of the element you want to acces For example we have a list just like in your case List = [42,55,67] If you want to acces 42the first element ib the list you would need to call List[0] the first element is marked as 0 cause Computer logic, the second element is List[1] and so on depending on the size of your list you can't acces a element outside of the lisg range in this case List[3] would cause an error.
15th Aug 2020, 9:39 AM
Christian Hauck
Christian Hauck - avatar
0
18th Feb 2021, 3:41 AM
Chinagey111
0
I didn't understand why the result is 2. In a list we start counting from 0, later 1,2,3 and so on.. We have 3 elements: [42, 55, 67] so my logic say that the 3rd element it is 67. Why is it 2 of the first element if 42 it is the zero position? Thank you so much who will reply me
10th Oct 2021, 2:41 PM
Federica De Iudicibus
Federica De Iudicibus - avatar
0
its ans is :- [ 2
13th Jan 2023, 1:55 PM
Engr.Ayesha Liaqat
Engr.Ayesha Liaqat - avatar