Graphics=['''
------------
| |''','''
------------
| |
| O''','''
------------
| |
| O
| / |''','''
------------
| |
| O
| / |
| | ''','''
------------
| |
| O
| / |
| |
| / |
|
| ''']
print("Welcome to Hangman! Guess the mystery word with less than 6 mistakes!")
words= ['utopian','fairy','tree','monday','blue']
i=int(input("Please enter a number (0<=number<10) to choose the word in the list: "))
if(words[i]):
print("The length of the word is: " , len(words[i]))
guesses=0
while guesses<6:
guess=input("Please enter the letter you guess: ")
guessed=''
guessed = guessed+guess[0]
if(guess in words[i]):
print("The letter is in the word.")
print(''.join(c if c in guessed else '_' for c in words[i]))
else:
print("The letter is not in the word.")
guesses=guesses+1
print("Letters matched so far:" ,''.join(c if c in guessed else '_' for c in words[i]))
if guesses==6:
print("Failure. The word was:" , words[i])
else:
print("You found the word!")
我在 Python 中的 Hangman 程序的最后一个问题。获得血腥的图形。这对我来说是最具挑战性的部分,因为我还没有通过我年轻的 Python 经验来处理 ASCII 艺术。我到底在哪里把这些图形放到程序中?在 else 语句下?