Python Forum
printing data from dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
printing data from dictionary
#3
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()
Reply


Messages In This Thread
printing data from dictionary - by kiki1113 - Nov-20-2017, 02:37 PM
RE: printing data from dictionary - by buran - Nov-20-2017, 03:31 PM
RE: printing data from dictionary - by heiner55 - Nov-20-2017, 03:31 PM
RE: printing data from dictionary - by kiki1113 - Nov-20-2017, 03:52 PM
RE: printing data from dictionary - by heiner55 - Nov-20-2017, 04:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Read data from a CSV file in S3 bucket and store it in a dictionary in python Rupini 3 7,088 May-15-2020, 04:57 PM
Last Post: snippsat
  Why is this function printing the number of keys in a dictionary? mafr97 5 3,132 Sep-17-2019, 06:19 AM
Last Post: perfringo
  Presenting data from a dictionary in a basic table ijosefson 3 3,366 Oct-16-2017, 04:13 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020