+ 1
i need help with list list=[1,2,3,4,5,6] print(list[list[4]])
what is going on here why does it print the last element?
7 Answers
+ 6
Indexes start at 0, so list[4] is the 5th element of the list, which is 5, and list[list[4]] is list[5], ie the 6th element of the list, 6.
+ 2
got it thank you
+ 1
wait so the first list of the list[list[4]] simply indexes one farther? so is it a complicated way of writing list[5] or does the nested list go first pulls the number from the list for the in nested list?
+ 1
list[list[4]] is only list[5] here because the 5th element of this particular array is 5.
0
because the last element of the list matches list[5]
0
num=7
if num>3:
print("3")
if num<5:
print("5")
if num==7
print ("7")
explain me briefly
0
spam=7
if spam>5:
print("5")
if spam>8
print ("eight")
Both statements are true but why it gives only first answer