我不太确定该怎么称呼这个职位。
无论如何,我想做的就是将'diff'分配给用户输入,如果'diff'不是平均值或高级,则调用该函数,以便用户可以(希望)输入平均值或高级。
但是,无论我输入了什么,即使输入是“平均”或“高级”,它也会始终调用该函数。
代码 -
def choices():
global diff
diff = input("Choose a difficulty: Average/Advanced ")
diff = diff.lower()
x = 0
while x > 1:
if diff == 'average':
print('Difficulty set to average.')
x = x + 1
elif diff == 'advanced':
print('Difficulty set to advanced.')
x = x + 1
if diff != 'average' or 'advanced':
print('Your input is invalid. Please try again.')
choices()
choices()
我做出的另一个与此类似的决定也发生了同样的事情,但我认为,如果遵循相同的逻辑,就没有必要放下它。
抱歉,这是一个愚蠢的问题。我只是一个初学者。
慕的地8271018
慕桂英3389331
相关分类