The following code will take a list of names and a list of greetings and combine them so one greeting will be applied with one name in the order of their index. Such as we say “hi susan”, “hola juan”, and so forth.
1.) How do I revise the following code so that I can store those in the greetings list for a future greeting for that individual and print the combined greeting list?
# Implemented as a While Loop.
names_list = ['susan', 'juan', 'wolfgang', 'piere', 'aednat']
greetings_list = ['hi', 'hola', 'tag', 'salut', 'haigh']
idx = 0
while idx < len(names_list):
greetings_list[idx] = greetings_list[idx] + " " + names_list[idx]
idx = idx + 1
print(greetings_list)
2.) How do I rewrite this code to use a for loop instead of the while loop?