+ 1

List Functions - Index

z= [2,3,45] z.insert(z[0],"MOO") print(z) the output is [2, 3, 'MOO', 45] which is not what i wanted. I wanted it to be ["MOO",2,3,45] What is wrong here ? I actually used the list index [0] to make space for the string "MOO" I could obviously to it directly and get the correct output -: z= [2,3,45] z.insert(0,"MOO") print(z) Output ['MOO',2,3,45]

6th Aug 2022, 2:26 PM
Rishabh Kaul
Rishabh Kaul - avatar
1 Antwort
+ 2
z.insert(0, "MOO")
6th Aug 2022, 2:32 PM
Jayakrishna 🇮🇳