這是我的代碼:的Python:類型錯誤:輸入預計最多1個參數,得到了3
print("Hello, what's your name?")
myName = sys.stdin.readline()
Join = input("Would you like to play a game, yes or no?").lower()
if Join.startswith('y'):
print("Fine, you can play.")
else:
print("Ok, goodbye.")
sys.exit()
Color = input("So, first question. What's your favorite colour,
or do you have none?").lower()
if Color.startswith("n"):
Thanks = input("Didn't expect much from you, good job", myName,
" Say thanks, I complimented you!").lower()
else:
print("Having a favorite colour is the wrong answer, try again.")
sys.exit()
if Thanks.lower() == 'thanks':
print("NEVER SAY THANKS!")
sys.exit()
else:
Continue = input("Well done, you didn't say THANKS.
Do you wish to continue, yes or no?").lower()
if Continue.startswith('y'):
print("Sure let's continue then.")
else:
print("Too bad, you HAVE to continue!")
sys.exit()
我是新來編程,而我只是做一個「笑話」的代碼進行練習。
Thanks = input("Didn't expect much from you, good job", myName, " Say thanks, I complimented you!").lower()
的錯誤是::但我一直在這條線得到一個錯誤
TypeError: input expected at most 1 arguments, got 3
你可以加入(串連)的字符串。逗號語法僅適用於「打印」功能,該功能會自動爲您加入。 – Aurora0001