How to manipulate single items with multiple lists? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to manipulate single items with multiple lists?

if I have 2 lists and I try to go through the lists simultaneously, how to write the proper code? i have list1=[1,2,3] and list2=[4,5,6], I try to run it with the for statement: for i in list: print("blabla",i,"blabla", and now I want to run it from list2 4, in the next line 5, and next one 6... it should look like this: blabla 1 blabla 4 blabla 2 blabla 5 blabla 3 blabla6 please help (*I am a beginner and I am trying to impress my wife :) )

27th Jul 2018, 7:31 PM
Mirza Kadric
Mirza Kadric - avatar
5 Answers
+ 15
You can do it like this: for i in range(3): print("blabla", list1[i], "blabla", list2[i]) P.S. Where do you get wives impressed by coding... 🤔😁
27th Jul 2018, 7:46 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
Kuba Siekierzyński well - I am deeply impressed by your code. (-;
27th Jul 2018, 8:04 PM
Oma Falk
Oma Falk - avatar
+ 3
... but maybe thanks to my age not your pray scheme. ... hachz...
27th Jul 2018, 8:05 PM
Oma Falk
Oma Falk - avatar
+ 1
aaaa I get it now, will try it, thanks a lot. P.S. Nowhere I guess... She showed me a photo and I said I'm gonna write it as a code, but I managed to screw up with the lists
27th Jul 2018, 7:50 PM
Mirza Kadric
Mirza Kadric - avatar
+ 1
I didn't find this detail anywhere, tough I tried many times to handle this. Anyways, it worked, thanks Kuba. I feel great I got it finally and I am more excited about it than my wife is...
27th Jul 2018, 8:17 PM
Mirza Kadric
Mirza Kadric - avatar