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!")
마지막으로 행맨 프로그램이 파이썬에서 한 가지 문제가 있습니다. 피 묻은 그래픽을 얻으십시오. 파이썬으로 저의 어린 경험을 통해 ASCII 아트를 다루지 않았으므로 이것이 가장 어려운 부분입니다. 정확히 어디에서이 그래픽을 프로그램에 넣을 수 있습니까? else 문 아래서?행맨 파이썬에 그래픽 추가하기
더 많은 문맥을 보지 않고도 당신을 도울 수는 없을 것입니다. 여기에 전체 코드를 게시 할 수 있습니까? –