How to add prefix in a list of string using list comprehension?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to add prefix in a list of string using list comprehension??

12th Jun 2021, 6:22 AM
Srishti
Srishti - avatar
2 Answers
+ 6
word = ["gain","build","pare","exam"] new_word = ["re-"+i for i in word] print(new_word )
12th Jun 2021, 6:34 AM
TOLUENE
TOLUENE - avatar
+ 2
w1 = ["java","car","ham","foo","spam"] w2 = ["script","pet","burger","bar","egg"] w = [p+w2[i] for i, p in enumerate(w1)] print(w)
12th Jun 2021, 11:17 AM
visph
visph - avatar