0

Python game.

How to write in python program: Ask the user about a letter then if it’s on the word print the letter on suitable place. For example: The word is Canada User input=d - - - - d - (how I can write like that)?

11/16/2019 3:20:56 PM

Alshaqsia Alshaqsi

4 Answers

New Answer

+3

I tried this and it works: word = "Canada" letters = [] for i in word: letters.append(i) letter = input() whattoprint = [] for i in letters: if i == letter: whattoprint.append(i) else: whattoprint.append("-") print("".join(whattoprint)) I hope this is helpful!

+2

Try this: word = 'Canada' letter = 'd' newword = '' for i in word: if i != letter: newword += '-' else: newword += i print(newword) https://code.sololearn.com/c9aHlq6kmh3b/?ref=app

+2

I had tried this, https://code.sololearn.com/cL0MRy3TS8wJ/?ref=app

0

it doesn’t work.