我只是在学习 python 并且无法理解为什么我的 if 输入触发了我的 else 语句。我确定我在这里遗漏了一些基本的东西,但希望有人看一下!本质上,当我输入一个变量时,它会将 else 语句拖入其中。我附上代码,谢谢您的观看!
n = 'Nike'
p = 'Puma'
a = 'Adidas'
boot = input('What is your favorite boot?')
if boot == n:
print('Nike, great choice')
if boot == a:
print('Adidas, not my favorite')
if boot == p:
print('Not sure about Puma')
else:
print('I am not familiar with that brand')
Run Code Online (Sandbox Code Playgroud)
在Nike输入打印上打字
Nike, great choice.
I'm not familiar with that brand.
Run Code Online (Sandbox Code Playgroud)