我想添加.lower()
来电,所以不要执行以下操作:
variable_name = input()
if variable_name == "example" or variable_name == "Example":
print ("whatever I want")
我想这样做
variable_name.lower() = input()
if variable_name == "example":
print ("whatever I want")
问题是,每当我这样做并运行程序时,它告诉我它不能分配给函数调用。我留下了一段代码供你查看。
#Variables and Imports Declerations
import sys
import os
awnser.lower() = " "
score = 0
#----------------------------------
while playagin == "yes":
#Welcome Message and Title
print ("GeneralQuiz")
print ("Welcome to GeneralQuiz!")
#Question 1
print ("What is the 10th letter of the alphabet?")
answer.lower() = input ()
if answer == "j":
print ("Congratulations! + 1 Score!")
score = score +1
else:
print("Incorrect! The answer is J!")
或
#Variables and Imports Declerations
import sys
import os
awnser = " "
score = 0
#----------------------------------
while playagin == "yes":
#Welcome Message and Title
print ("GeneralQuiz")
print ("Welcome to GeneralQuiz!")
#Question 1
print ("What is the 10th letter of the alphabet?")
answer.lower() = input ()
if answer == "j":
print ("Congratulations! + 1 Score!")
score = score +1
else:
print("Incorrect! The answer is J!")
答案 0 :(得分:0)
与错误一样,您无法分配给函数调用。 variable_name.lower()
是函数调用。
您已将通话置于错误的位置。您想在input
:
variable_name = input().lower()