我是一个初学者的python程序员。请需要帮助。
lightcolor=int(input("Enter Red,Green,Yellow,White,Purple,Blue,Orange,Brown,or Black->"))
if lightcolor=="Red":
print("Red Light-Please stop!!")
elif lightcolor=="Green":
print("Green Light-Please continue")
elif lightcolor=="Yellow":
print("Yellow Light-speed up")
elif lightcolor=="White":
print("White Light-its too bright")
elif lightcolor=="Purple":
print("Purple Light-pretty")
elif lightcolor=="Blue":
print("Blue Light-thats unusual")
elif lightcolor=="Orange":
print("Orange Light-bright as the sun")
elif lightcolor=="Brown":
print("Brown Light-like dirt")
elif lightcolor=="Black":
print("Black Light-very dark")
else:
print("Sorry no such color"),lightcolor
为什么每次输入任何颜色时都会得到带有基本错误的 int() 的无效文字?我正在使用 python 3。坦克寻求帮助我修复了 int 并且它起作用了。