所以我在做一个骆驼游戏,我得到一个奇怪的错误
"TypeError: '>' not supported between instances of 'tuple' and 'int'"
我不知道这意味着什么,我已经张贴了,我将再次声明这一点,我是一个初学者编码器。感谢任何人在这里的帮助是代码,我会把你的错误放在评论的地方!在
import random
done = False
milesTraveled = 0
thirst = 0
camelTired = 0
nativesDis = -20
canteens = 5
print('''
Welcome to Camel!
You have stolen a camel to make your way across the great Mobi desert.
The natives want their camel back and are chasing you down! Survive your
desert trek and outrun the natives. ''')
while not done:
oasis = (1,21)
if oasis == 4:
print("You found an oasis!")
canteens = 5
thrist = 0
if thirst > 6:
print("You died of thrist!")
spc = input("")
done = True
if thirst > 4:
print("You are thirsty")
#under here
if camelTired > 8:
print("Your camel DIED!")
spc = input("")
done = True
if camelTired > 5:
print("Your camel is getting tired")
if nativesDis == milesTraveled + 20:
print('The natives caught up with you!')
spc=input("")
done = True
if milesTraveled == 200:
print('You Win!')
spc = input("")
done = True
print('''
A. Drink from your canteen.
B. Ahead full speed.
C. Stop and rest.
D. Status check.
Q. Quit ''')
user_choice = input("")
if user_choice.upper() == 'Q':
done = True
elif user_choice.upper() == 'D':
print('''
Miles Traveled: 0
Drinks In Canteen:''',canteens,'''
Thirstyness:''',thirst,'''
The Natives Are 20 Miles Behind You''')
elif user_choice.upper() == 'C':
camelTired = 0
nativesDis = random.randint(7,15)
elif user_choice.upper() == 'B':
milesTraveled = random.randint(10,22)
print("You traveled",milesTraveled,"miles!")
thirst + 1
camelTired = (1,3)
nativesDis = (7,14)
elif user_choice.upper() == 'A':
if canteens > 0:
canteens = canteens - 1
thirst
=0
您需要从元组中取出数字,并将其放入一个也是整数的变量中。在
元组中有多个整数。在
您可以通过以下方式访问它们:
或者直接从元组本身开始,而不创建新变量(在处理大量索引和元组时,这有时会变得不可读)。在
^{pr2}$然后您可以轻松地比较其他值。在
例如,如果需要将元组中的字符串与另一个整数进行比较,则可以通过执行以下操作来更改它:
相关问题 更多 >
编程相关推荐