出于某种原因,当我点击 c 时,它给我的“课程”没有定义。
请输入菜单选项... [c]ourses、[i]nstructors、[t]times:c Traceback(最近一次通话最后一次):
第 15 行,在主打印中(create_info(courses)) NameError: global name 'courses' is not defined
def main():
courseInfo = create_info()
print('Please enter a menu choice...')
choice = input('[c]ourses, [i]nstructors, [t]imes: ').upper()
if choice == 'C':
print(create_info(courses))
def create_info():
courses = {'CS101':'3004', 'CS102':'4501', 'CS103':'6755', 'NT110':'1244',
'CM241':'1411'}
instructors = {'CS101':'Haynes', 'CS102':'Alvarado', 'CS103':'Rich',
'NT110':'Burke', 'CM241':'Lee'}
times = {'CS101':'8:00 a.m.', 'CS102':'9:00 a.m.', 'CS103':'10:00 a.m.',
'NT110':'11:00 a.m.', 'CM241':'1:00 p.m.'}
return courses, instructors, times
main()