Python Forum
python dictionary for students records
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python dictionary for students records
#11
(Nov-12-2017, 03:21 PM)heiner55 Wrote: Ok, I understood, but you should also code something.
And moving code into the loop, that is the easy part.
this is what confused me from the beginning.
Reply
#12
#!/usr/bin/python3
students_DB={}
student_number=None

#ask input from user or 'q' to exit
while True:
    line = input('Please input the ID and name separated by comma or q to exit: ')
    if line == 'q':
        break

    id, name = line.split(',')
    students_DB.update({id:name})

    #output
    for key in students_DB:
        print('{}: name is {}'.format(key, students_DB[key]))
Reply
#13
thanks a lot
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Top 3 students banidjamali 4 2,343 Jan-17-2021, 11:59 AM
Last Post: banidjamali
  python program that calculat grades of students biligorm 3 2,232 Apr-04-2020, 10:11 AM
Last Post: buran

Forum Jump:

User Panel Messages

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