'How can I get information from separate dictionary module to import and print on new module
Below I have included the dictionary info module as well as the separate module where I'm trying to import the data to. I get errors in my code stating unexpected indent and then when I try to fix it, it states it needs to indent. At a loss on how to get my code to run. Second module starts at "import employeedata".
def employee_info(name, detail):
database = {'John':{
'salary': '$100,000',
'title': 'Software engineer',
'address': '1001 ocean drive',
'phone':'303-919-6425'},
'Angelica': {
'salary': '$95,000',
'title': 'Project Manager',
'address': '532 Amrillo Blvd',
'phone':'787-512-7601'}
}
try:
input_value = database[name][detail]
print(f"{name}'s {detail} is {input_value}")
except KeyError:
print("Input not found.")`
import employeedata
salary = 1
title = 2
address = 3
phone = 4
quit = 5
employee_name = 'John' or 'Angelica'
def employeeFinder():
employee_name = input("Please enter the name of the employee to see their respective information: ")
def show_menu():
print('Menu')
print('1) Employee salary')
print('2) Employee title')
print('3) Employee address')
print('4) Employee phone')
print('5) Quit')
while choice != quit:
def employeechoice():
choice = 0
choice = int(input('What would you like to see?: '))
if choice == 1:
print(employeedata[employee_name][salary])
elif choice == 2:
print(employeedata[employee_name][title])
elif choice == 3:
print(employeedata[employee_name][address])
elif choice == 4:
print(employeedata[employee_name][phone])
elif choice == 5:
print("Nothing else? Goodbye.")
if employee_name not in employeedata:
print("The employee name you entered does not exist in the system.")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
