我决定做一个小任务,但我遇到了这个错误 NameError: name 'per' is not defined 这个错误出现并且 NameError: name 'vid' is not defined 也像这个 NameError: name 'vih' is not defined。请帮帮我!
import random
print("")
vid = int(input())
if vid == 1:
print("")
print("")
print("")
if vid == 2:
print("")
raise SystemExit
guess = random.randint(1,6)
print("")
print(guess)
if guess == 1:
print("")
print("")
vih = input()
if guess == 2:
print("")
print("")
if guess == 3:
print("")
if guess == 4:
print("")
print("")
per = input()
if guess == 5:
print("")
print("")
if guess == 6:
print("")
print("")
if vih == "":
print("")
print("")
print("")
if vih == "":
print(" ")
if per == "":
print("")
print("")
print("")
if per == "":
print("")
print("")
您遇到的问题是,当您检查 vih 时,不确定 vih = input() 是否已执行。试试这个。它似乎工作。