以下是我的脚本,我不断收到错误:
无法分配给运营商
nine = 9
ten = 12
nine + ten = 21
print (" Hello, this is going to test your mathematical ability.")
print ("What is nine + ten?")
if 21 == nine + ten:
print ("You're stupid")
else:
print ("You're wrong!")
我真的很喜欢Python,所以请清楚地解释一下代码。
答案 0 :(得分:2)
我假设您的代码看起来像这样;
nine = 9
ten = 12
nine + ten = 21
print (" Hello, this is going to test your mathematical ability")
print ("what is nine + ten?")
if 21 == nine + ten:
print ("you stupid")
else:
print ("you're wrong!")
在第3行,你将“九+十”分配给值21.这不是有效的语法,而是给你错误。
即使这是有效的语法,您的代码也会始终打印“你很蠢”,因为9 + 10将始终具有值21。