+ 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]
1 Respuesta
+ 2
z.insert(0, "MOO")