What is happening here? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is happening here?

number = 3 things = ["string", 0, [1, 2, number], 4.56] print(things[1]) print(things[2]) print(things[2][2]) What is the last line of code doing?

26th Apr 2020, 4:51 PM
Naresh Padmanaban
Naresh Padmanaban - avatar
4 Answers
0
Outputs 0 [1,2,number] number
26th Apr 2020, 4:54 PM
Abhay
Abhay - avatar
0
You should play around by changing index numbers and go through python course as well to understand what's exactly happening ,
26th Apr 2020, 4:55 PM
Abhay
Abhay - avatar
0
things is a list with 4 elements. one of these elements is also a string.
26th Apr 2020, 4:55 PM
Alexander Thiem
Alexander Thiem - avatar
0
In the last line print(things[2][2]) things[2] will give you [1,2,number] Now from this list [1,2,number] you have to print the value of index no.2 which is number i.e. 3 Hence last line will give the output 3
26th Apr 2020, 5:15 PM
ANJALI SAHU