我试图让它,如果你有一个词“人”,例如,它会像这样。如果用户键入“m”,它将看起来像m\uuu。我知道我的问题在于for循环下的“#Where user will type guess”注释 随机导入
user_input = ""
turns = 5
# List of words
print("Welcome to Advanced Hang Man!")
guesses = ["hello"]
# Picks a random word from the list and prints the length of it
random_guesses = (random.choice(guesses))
right_guess = []
wrong_guess = []
# Prints the hidden word in "_" format
hidden_word = "_" * len(random_guesses)
print(hidden_word)
# Where user will type guess
while True:
user_input = input("Please enter a letter once at a time:")
user_input = user_input.lower()
for i in range(len(random_guesses)):
if user_input == random_guesses[i]:
print(hidden_words)
这是我做游戏的尝试。我没有使用你的
right_guesses
列表,也没有使用wrong-guesses
列表,但它具有恒人游戏的基本功能:您需要迭代实际单词并检查
right_guesses
列表中的字符。如果找不到,在新单词中用_
替换字符。下面是实现这一点的示例代码:相关问题 更多 >
编程相关推荐