当我自己不知道随机选择是什么时,如何保存随机选择?


import random
print(
"Do you think you know all the animals😺😼?! if yes then this game is for 33[1myou!33[0m")
print("33[7m""Let the game begin! ""33[0m")
animals = ("ant baboon badger bat bear beaver camel cat clam cobra cougar").split()
you_chose = []
animal = random.choice(animals)
hint = random.choice(list(animal))
used_hints = []
lives = 6
hint_count = 6
while True:
print()
letter = input("please type a letter to begin:  ").lower()
if letter in you_chose:
print("33[31m Error doublicate letter33[0m")
continue
else:
you_chose.append(letter)
if letter in animal:
print("Congrats, you found a letter! keep going.")
else:
print("Not in there keep trying")
lives = -1
want_hint = input("Would you like a hint?(yes  No)n: ").lower()
if want_hint == "yes":
for want_hint in hint:
if want_hint not in used_hints and want_hint not in you_chose:
hint_count += 1
print(hint, end="")
used_hints.append(want_hint)
else:
continue
for letter in animal:
if letter in you_chose:
print(letter, end="")
else:
print("*", end="")

#问题-我需要保存随机动物,然后转向一个列表用作提示游戏但随着游戏的一段真实的循环我们第一次要求提示天气给原始动物但是下次提示就从猫狗我需要保存值的随机选择了之前把它变成一个提示我试着种子函数作为我新的代码认为这样一来工作没有

试试这样做,这将使动物字符串输入到一个列表:

animals = list(动物)随机选择(动物)打印(动物)

或尝试:动物= ['cat','human','dog','bird'…]随机选择(动物)打印(动物)

最新更新