vacation_poll = {}
name_prompt = "\nWhat is your name? "
vacation_spot_prompt = "\nWhere would you like to go on vacation? "
repeat_prompt = "\nWould you like to continue? (yes/no) "
active = True
while active:
name = input(name_prompt)
vacation_spot = input(vacation_spot_prompt)
vacation_poll[name] = [vacation_spot]
repeat = input(repeat_prompt)
if repeat == 'no':
active = False
for name, spots in vacation_poll.items():
print("\nThese are " + name.title() + "'s places of interest: ")
for spot in spots:
print("\t" + spot.title())
print(vacation_poll)
My goal is to append a new vacation spot in a list inside the dictionary vacation_poll when the same key shows up. So if Joe shows up again after I continue the loop, the new vacation spot should be added to Joe's list of vacation spots, but instead I get it overwritten. I've tried to append using a for loop, but that didn't work either. How could I fix it to append a new value to the list each time the loop is continued?