python中input错误_Python名称错误:未定义名称“input”

我正在尝试在Python上构建一个程序。这是程序的一部分,问题就在这里。当我在Python中运行它时,它通过'task_name=input(“What is the task”)行运行,但是当我把它放到Python visualizer时,它给了我一个错误:NameError:name'input'没有定义。下面这段程序只是我程序的开始,在它运行完这段程序之后,我需要它来运行我程序的其余部分,但是它会停止并重复这个部分。如果我没有很好地解释这一点,我很抱歉,如果你不明白,尽管问。请回答,我需要在明天之前完成这个程序!

我使用了pythonvisualizerhttp://www.pythontutor.com/visualize.html#mode=display,我使用的是python3.2.1.1newTask = "y"

while newTask == "y":

try:

numStudents = int(input("How many students are there?"))

except ValueError:

print("An integer please")

continue

else:

if numStudents <=1:

print("You must enter more than 1 student.")

task_name = input("What is the task?")

while numStudents == 0:

for i in range (1,numStudents):

cont = "y"

while cont == "y":

import random

vol_num = random.randint (1,numStudents)

print(vol_num) #remove, needs to be hidden

break

print("The task is", task_name, ".", "If your number matches the secret number you must complete this task. Good luck!!")

print("There are", numStudents-student_num, "numbers left which means you have 1 chance in", numStudents, "of being the volunteer!")

student_name = input("What is your name? Please enter your first name in letters with a maximum of 15.")

while student_name.isalpha() != True or len(task_name) > 15:

print("Your first name must be entered in letters with a maximum of 15 letters.")

student_name = input("What is your name?")

student_num == 0

while student_num == 0:

try:

student_num = int(input("What is your number? Please enter it as an integer."))

except ValueError:

print("You number must be entered as an integer.")

continue

else:

if student_num < 1 or student_num > numStudents:

print("That is not a valid number. Please enter the number you were given.")

student_num = int(input("What is your number?"))

if student_num == vol_num:

print("You are the volunteer! Please complete the task of", task_name, ".")

else:

print("You were lucky this time! You do not have to complete the task!")

cont = input("Are you the next student? y/n")

while cont == "n":

newTask = input("Would you like to enter a new task? (y/n")

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值