Create a function that will accept a person's name and age, address, birthdate, email, if he/she has a job, what is the job title, and put all those data in a dictionary.
Answer to this question.
def add_person_dictionary():
dictionary_fields = ['name', 'age', 'address', 'date of birth', 'email', 'job position']
required_to_fill = [True, True, True, True, True, False]
re_dictionary={}
i=0
while i<len(dictionary_fields):
in_data = input('Please, enter '+dictionary_fields[i]+':')
if in_data=='' and required_to_fill[i]:
print("This field cannot be empty")
else:
if in_data!='':
re_dictionary[dictionary_fields[i]]=in_data
i=i+1
return re_dictionary
Comments
Leave a comment