TypeError: can only concatenate str (not "tuple") to str How do i fix this?

TypeError: can only concatenate str (not "tuple") to str How do i fix this?

所以我是一个相当新的 python 用户,我正在尝试制作剪刀石头布游戏,您可以在其中与 AI 对战,也可以模拟 2 个真人(本地游戏),但是我不断收到此错误:

TypeError: can only concatenate str (not "tuple") to str

这是出现问题的代码行:

print("Hello" + User1 + "and" + User2 +  "please enter 2 again")

print(User1 + " played " + x)

print(User2 + " played " + y)

下面是整个代码的 link: https://i.stack.imgur.com/XKzVA.png 任何帮助将不胜感激。

您已在此处将您的用户名初始化为空元组:

User1 = ()
User2 = ()

在您的 print 语句中,您尝试将一个字符串与该元组连接起来:

print("Hello" + User1 + "and" + User2 +  "please enter 2 again")

Python 没有定义元组和字符串之间的加法,因此会抛出类型错误。我建议将您的用户名定义为空字符串,直到您决定如何处理他们进入您的程序。