+ 1
Lists
list = [ 42, 55, 67] print(list[ 2 ]) Explain me this Question?
5 Respostas
+ 1
Hi,
3rd entry of list is asked
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.
0
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
0
its ans is :-
[
2