+ 1
Why the word is not hidden from player 2?
I tried the hidden. appered('__') https://code.sololearn.com/cblFJXvZq474/?ref=app https://code.sololearn.com/cblFJXvZq474/?ref=app
7 ответов
+ 1
Amxl Amixul
lst = []
answer = input("Player 1: ")
for i in answer:
lst.append("_.")
print(''.join(lst))
guess = input("Player 2: ")
print("Won" if guess == answer else "Lost")
+ 1
'' in ''. join(lst) are two quotation marks. you can also use "". join(lst)
+ 1
Sorry I mention put the mark up to you
+ 1
Amxl Amixul if u r wondering why i used "".join then heres why:
When we want a list to join together
["Hello", "there", "friend"]
If we join this list by "".join and print it,
Hellotherefriend is the output.
Whatever we pass inside " ".join would separate these words otherwise it would join then without space.
"//".join(lst) would mean
Hello//there//friend
+ 1
Thank you maf for the good examples I wonder why does it show the word of the players 1 put it should be in hidden from player 2 also could not used the players to guess one word at the time rather the whole word
0
Is not working your code
Print(". Join(lst))
Is not executed is an error
0
Amxl Amixul I found a way.
just use getpass() instead of input(). But you would have to import it first.
import getpass
hidepw = []
pw = getpass.getpass("Password: ")
for i in pw:
hidepw.append("_.")
print(''.join(hidepw))
guess = input("Enter guess: ")
print("WON" if guess == pw else "LOST")