a=int(input("please input number of players "))
while (a < 2):
a=int(input("please input at least two players "))
if (a==2):
p1=input("please enter name for player 1 ")
p2=input("please enter name for player 2 ")
x=float(input("please enter initiative for "+(p1)))
y=float(input("please enter initiative for "+(p2)))
x=x,p1
y=y,p2
if (x > y):
lowest=y
highest=x
elif(y > x):
lowest=x
highest=y
print(lowest)
steps=int(input("Please enter number of steps for "+(lowest)+" action" ))
我已经想尽了一切办法,但我想不出该怎么做
这正是消息所说的:在最后一行,在子表达式中
您正在尝试将字符串与元组(
lowest
)连接,因为它要么是x
,要么是y
,并且由于分配x=x,p1
和y=y,p2
,这两个元组都是元组,这需要从元组到字符串的隐式转换。要解决这个问题,您必须显式地将元组转换为字符串(
str(lowest)
)(尽管我怀疑您实际上只想显示元组的一个元素)。相关问题 更多 >
编程相关推荐