나는 while 루프의 포맷팅을 진행할 것이고, 나는 이것을 고칠 수있는 방법에 대해 확신 할 수 없다. (나는 초보자 다. 어떤 도움이라도 대단히 감사하겠습니다! 나는 사용자가 힌트를 요청할 때 '미안하지만 그 메시지가 아닙니다'라는 메시지가 나타나기를 원하지 않는다.while 루프가 시작될 때 나는 그것을하지 않기를 원한다.
# Word Jumble
#
# The computer picks a random word and then "jumbles" it
# The player has to guess the original word
import random
# create a sequence of words to choose from
WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone")
# pick one word randomly from the sequence
word = random.choice(WORDS)
hint = ''
if word == 'python':
hint = 'snake'
if word == 'jumble':
hint = 'jumble'
if word == 'easy':
hint = 'opposite of hard'
if word == 'difficult':
hint = 'opposite of easy'
if word == 'answer':
hint = 'question'
if word == 'xylophone':
hint = 'dingding'
# create a variable to use later to see if the guess is correct
correct = word
# create a jumbled version of the word
jumble =""
while word:
position = random.randrange(len(word))
jumble += word[position]
word = word[:position] + word[(position + 1):]
count = 0
# start the game
print(
"""
Welcome to Word Jumble!
Unscramble the letters to make a word.
(Press the enter key at the prompt to quit.)
"""
)
print("The jumble is:", jumble)
guess = input("\nYour guess: ")
while guess != correct and guess != "":
print("Sorry, that's not it.")
count += 1
hint_input = input('would you like a hint')
if hint_input == 'y':
print(hint)
else:
guess = input("Your guess: ")
if guess == correct:
print("That's it! You guessed it!\n")
print("Thanks for playing.")
input("\n\nPress the enter key to exit.")
어떤 오류 메시지가 나타납니다? – CDspace
전체 스택 추적을 제공하여 코드에 무엇이 잘못되었는지 확인할 수 있습니다. – Paco
죄송합니다. 내 말씨가 꺼져있었습니다. 오류가 아닙니다. 설명에서 수정 됨 – Zack