首页 > 解决方案 > 它说 NameError: name 'Doctor' is not defined 当我尝试执行

问题描述

#Program that outputs quote for 3 jobs and outputs a sorry message >if an unrecognised job is used

#Subroutine to describe job
def Desc(Job):
    if Job == 1:
        print("Seeing what other people cant see gives you great vision")
    elif Job == 2:
        print("Logical thinking, passion and perseverance is the paint on your palette.")
    elif Job == 3:
        print("The engineer has been,and is,a maker of history.")
    else:
        print("Sorry, we could not find a quote for your job")

Analyst = 1
Developer = 2
Engineer = 3

#Main program
Desc(Doctor)

标签: python

解决方案


您没有设置变量“医生”。例如,您需要编写:

Doctor = 1
Desc(Doctor)

推荐阅读