Ex9 - Dictionaries:

Description:

  1. Name the file Ex9-Dictionaries.py.
  2. Define a dictionary called users.
  3. Add three users (for example: Bernard, Charlotte, Teddy) as keys in the users dictionary.
  4. For each user, create a nested dictionary similar to the cities example as the value that includes:
  • role
  • securityQuestion
  • securityAnswer
  1. In the terminal, print each user’s name and all stored information by looping through the users dictionary. Use the following format for the output:
  • Solution Output Example:

1User: Bernard
2    Role: Administrator
3    Chose the following secuirty question: What was the name of your first dog?
4    Answered to the security question: Scully.
5
6User: Charlotte
7    Role: Guest
8    Chose the following secuirty question: What is your favorite color?
9    Answered to the security question: Purple.
10
11User: Teddy
12    Role: Guest
13    Chose the following secuirty question: In which city were you born?
14    Answered to the security question: Cullowhee.