+ 2

Understanding lists.

Why does the output compute to 6 in the second example? 1st Example: list = [1, 2, 3, 4, 5, 6] print(list[4]) output: 5 2nd Example: list= [1, 2, 3, 4, 5, 6] print(list(list[4])) output: 6 I understand the basics of lists, but not the second example. Could someone please elaborate in detail for me so I can understand? I’m a beginner programmer in Python, and programming in general, so please bear with me.

26th Feb 2018, 6:09 PM
Christopher Millett
Christopher Millett - avatar
2 ответов
+ 4
first list output is 5 print (list(list[4]))=print(list(5)) Show list[5]=output 6 on monitor so answer is 6
26th Feb 2018, 6:27 PM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar
0
Thanks dude!
27th Feb 2018, 4:53 PM
Christopher Millett
Christopher Millett - avatar