Python 입문. 저는이 코드를 작성하고 있습니다. 수영과 싸이클을위한 입력이 'Y'와 'N'의 조합 일 때, 내 프로그램에서 else 문 (yourName, '연습이 필요함) . 내가 도대체 뭘 잘못하고있는 겁니까? 수영 만약, 위의 예를 들어, 파이썬에서입력을 불리언 표현식과 비교하는 파이썬
if swim is 'Y' and cycling is 'Y' or swim is 'y' and cycling is 'y':
:
def main():
yourName = input("What is the your name? ")
swim = input("Can you swim <Y>es or <N>o? ")
cycling = input("Can you cycle <Y>es or <N>o? ")
if swim and cycling is 'Y' or swim and cycling is 'y':
print(yourName, 'is an athlete.')
elif swim and cycling is 'N' or swim and cycling is 'n':
print(yourName,'shows potential.')
else:
print(yourName,'needs practise')
main()
예. 따라서 두 입력이 모두 'y'이면 사람은 운동 선수가됩니다. 둘 다 'n'이면 연습이 필요하지만 입력 중 하나가 'y'이고 다른 하나가 'n'이면 잠재적 진술이 표시되기를 원합니다. – Tom