belongs to collection: Python List Exercises
list1 = ["Hello ", "take "] list2 = ["Dear", "Sir"]
Expected output:
['Hello Dear', 'Hello Sir', 'take Dear', 'take Sir']
Hint:
Use a list comprehension to iterate two lists using a for loop and concatenate the current item of each list.
Solution:
list1 = ["Hello ", "take "] list2 = ["Dear", "Sir"] res = [x + y for x in list1 for y in list2] print(res)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
Use a list comprehension to iterate two lists using a for loop and concatenate the current item of each list.
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer