Nov-20-2017, 03:52 PM
(Nov-20-2017, 03:31 PM)heiner55 Wrote:def data(): people = int(input("How many individuals are attending? ")) attendees = {} for i in range(people): name = str(input('Please enter name: ')) amount = int(input('Number of toys donated:')) attendees[name] = amount return attendees def print_data(): attendees = data() print('Level 1') for i in attendees: if attendees[i] > 20: print(i, attendees[i]) print('Level 2') for i in attendees: if attendees[i] <= 20: print(i, attendees[i]) print_data()
Thanks for your reply. While this gets me closer, it also only prints on entry. When I modify my code as suggested, it only allows me to enter one name before it prints the name/level. So if I entered 3 attendees would be attending, it only gives me the chance to enter the first name and then immediately moves to the second function to print the name.
This also makes me think that I want to modify it further to only print the level name if there are entries that apply. In other words, if there are no entries that would fall into level 2, then it should not print the level 2 header.