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ステートメントの下?