执行一段关于if的程式,但没有得到预期的回传值
我在学习 if 语句时,尝试输入一段代码。如下:我本来预期结果是
‘Nonsense’
‘Nonsense’
‘Nonsense’, 但实际结果是
Do you want to play cf?
Do you want to play cs?
Do you want to play lol?
这是为什么呢?
games = ['cf', 'cs', 'lol']
for game in games:
if game == 'CF' or 'CS':
if game == 'CF':
print(f"Do you want to play {game}?")
else:
print(f"Do you want to play {game}?")
elif game=='LOL':
print("Do you want to play LOL?")
else:
print('Nonsense!')
推荐文章: