Python的运营商和如果条件[关闭]

问题描述 投票:-5回答:1

我的代码:

answer = str(raw_input("Is the information correct? Enter Y for yes or N for no"))
if answer == "y" or answer == "Y":
  print("this will do the calculation")
else:
  exit()

就是这个样子的正确使用条件与OR操作?

python string if-statement operator-keyword
1个回答
1
投票

是的,这是一个正确的使用或经营者,你可以尽量避免使用的或使输入较低或大写,但我明白的问题,你更感兴趣的是有效的或句法。

© www.soinside.com 2019 - 2024. All rights reserved.