insert | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

insert

my_list=[(1,2,3,4) , (100,200,300)] I want to insert 400 to the first index of my_list (i mean (100,200,300) but i don't know how !help please

24th Jun 2017, 4:25 PM
kazuto
1 Answer
+ 1
You can use insert method. But in your list you have tuples which are immutable. If replace them to lists you can insert any data. my_list=[(1,2,3,4),[100,200,300]] my_list[1].insert(3,400) Other way: my_list[1].append(400)
24th Jun 2017, 5:23 PM
Александр Громозонов
Александр Громозонов - avatar