+ 1
Nested List
a = ['a', 'b'] n = [1, 2] x = [a, n] print(x[1]) Output [1, 2] Why the output is [1, 2]?
6 Respuestas
+ 8
x = [a,b],[1,2]
0 1
So, x[1] = [1,2]
+ 7
Ausgrindtube,
> the content of x is => [['a', 'b'], [1, 2]]
+ 5
Happy to help!
+ 4
Completely correct Lothar . Thanks
+ 3
Ooooh. Got it. Thank you so much👌
+ 1
Hola the answer is [1, 2] because of the index you've placed inside x. Please remember that List are ordered and changeable.
print(x[1])
Outputs:
[1, 2]
print(x[0])
Outputs:
['a', 'b']
print(x)
Outputs:
[['a', 'b'], [1, 2]]
ref1: https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_lists.asp