Я выучил основные понятия Списка, Кортежей и Словари вместе с условным утверждением. И начал писать простой кусок кода, чтобы принять ввод пользователя и создать словарь из введенных вводов и распечатать содержимое словаря.
Код написан -
patientCount = 0
noOfPatients = input("\nHow many Patient's to Admit: ")
while (patientCount < int(noOfPatients)):
print("\nEnter the Details of the Patient {} :".format(patientCount+1))
patientFirstName = input("{:>30}".format("Enter the FIRST NAME: "))
patientLastName = input("{:>30}".format("Enter the LAST NAME: "))
patientMRN = input("{:>30}".format("Enter the MRN: "))
patientGender = input("{:>30}".format("Enter the GENDER (M/F/O): "))
patientBirthYear = input("{:>30}".format("Enter the BIRTH YEAR: "))
patientAge = input("{:>30}".format("Enter the AGE: "))
patientCount +=1
КОНСОЛЬНЫЙ ВЫХОД:
How many Patient's to Admit ?: 2
Enter the Details of the Patient 1 :
Enter the FIRST NAME: David
Enter the LAST NAME: John
Enter the MRN: 878783
Enter the GENDER (M/F/O): M
Enter the BIRTH YEAR (YYYY): 1901
Patient AGE is: 117 Years
-------------------------
Enter the Details of the Patient 2 :
Enter the FIRST NAME: Sam
Enter the LAST NAME: Tommy
Enter the MRN: 76487236
Enter the GENDER (M/F/O): F
Enter the BIRTH YEAR (YYYY): 1990
Patient AGE is: 28 Years
Создан начальный пустой словарь как -
patientDatabase = {}
Я хочу создать вложенный словарь, как показано ниже из введенных выше вводов в коде -
patientDatabase = {
Patient 1:{'First Name':'David', 'Last Name': 'John',
'MRN': 878783, 'Gender': 'M', BirthYear': 1901, 'Age': 117},
Patient2:{'First Name':'Sam', 'Last Name': 'Tommy',
'MRN': 76487236, 'Gender': 'F', BirthYear': 1990, 'Age': 28} }
А когда напечатан вышеупомянутый словарь, ВЫХОД, который я ищу, как показано ниже -
Patient 1 Details:
--------------------
FIRST NAME: David
LAST NAME: John
MRN: 878783
GENDER: M
BIRTH YEAR: 1901
AGE: 117 Years
Patient 2 Details:
--------------------
FIRST NAME: Sam
LAST NAME: Tommy
MRN: 76487236
GENDER: F
BIRTH YEAR: 1990
AGE: 28 Years
Может ли кто-нибудь помочь мне?