1
내가 인쇄 문에 변수를두고있어, 나는이 오류 메시지가 얻을 : 난 그냥 배우고파이썬 변수
'''
Created on Apr 17, 2017
@author: Samuel
'''
game = input("Would you like to play a game? Please answer with \"Yes\" or \"No\".")
game = game.lower()
if game == "yes":
print("Great! Let's play.")
elif game == "no":
print("Ok, I guess we won't play.")
else:
print("Dude, %s is not yes or no... come on.") %(game)
: 이것은 내 코드입니다
Traceback (most recent call last):
File "C:\Users\Samuel\workspace\First Python Project\com\fireboxtraining\Person.py", line 13, in <module>
print("Dude, %s is not yes or no... come on.") % (game)
TypeError: unsupported operand type(s) for %: 'NoneType' and 'str'
을 파이썬이 왜 작동하지 않는지 이해할 수 없습니다. 도와주세요!
당신은 당신이 입력 어떤 대답을하지 않을 때 경우를 처리 할 필요가있다. 값이 비어 있거나 없음이므로 인쇄하는 것이 의미가 없습니다. – anonyXmous
마지막 행은'print ("Dude, % s는 예 또는 아니요 ..."% (game)) "입니다. 'print' 오른쪽 괄호에 유의하십시오. – pkuphy