Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
20
12
85
10.7K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Answer: [1, 10, 2, 3] insert(1, 10) places 10 at index 1 (second position) and shifts the remaining elements to the right.
English
0
0
7
693
Prince Cobbina
Prince Cobbina@CobbinaCodes·
@PythonPr It would be [1, 10, 2, 3] This is because python lists count from 0 Meaning what would be the first item in a list has the index 0
English
0
0
0
250
laso
laso@lasitolas·
@PythonPr 1,10, 2 ,3...insert method acts on the list by inserting at index 1 the value 10
English
0
0
0
127
Jeff
Jeff@Jeff72571425107·
@PythonPr x=[1,10,2,3] x=[1,2,3] and then x.insert(1,10) insert 10 at location 1 you start the index location at zero so 1 is the second element in the list
English
0
0
0
22
Paylaş