Как заменить подчеркивания выбранными буквами в HangmanPython

Программы на Python
Anonymous
 Как заменить подчеркивания выбранными буквами в Hangman

Сообщение Anonymous »

В моем фрагменте кода возникла проблема с заменой символов подчеркивания, отображаемых длиной слова, на правильные буквы. Как мне решить эту проблему?

Ниже приведен пример запускаемого моего кода.

print("Welcome to Python Hangman")
print()

import random # Needed to make a random choice
from turtle import * #Needed to draw line

WORDS= ("variable", "python", "turtle", "string", "loop")

word= random.choice(WORDS)#chooses randomly from the choice of words
print ("The word is", len(word), "letters long.")# used to show how many letters are in the random word

space = len(word)
underscore = ("_ " * space)
print(underscore)

for i in range(1, 9):#gives the amount of guesses allocated
letter = input("Guess a letter ")
if letter in word:
print ("Correct", letter)#if guesses letter is correct print correct
else:
print ("Incorrect", " ",letter)
#if its wrong print incorecct



Подробнее здесь: https://stackoverflow.com/questions/338 ... in-hangman

Вернуться в «Python»