Answer to Question #350201 in Python for ayen

Question #350201

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.


1
Expert's answer
2022-06-13T08:26:26-0400

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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS