Why the word is not hidden from player 2? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

1st Apr 2020, 5:56 PM
Amxl Amixul
Amxl Amixul - avatar
7 Answers
+ 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")
1st Apr 2020, 6:21 PM
maf
maf - avatar
+ 1
'' in ''. join(lst) are two quotation marks. you can also use "". join(lst)
1st Apr 2020, 6:42 PM
John Robotane
John Robotane - avatar
+ 1
Sorry I mention put the mark up to you
1st Apr 2020, 6:57 PM
Amxl Amixul
Amxl Amixul - avatar
+ 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
1st Apr 2020, 6:59 PM
maf
maf - avatar
+ 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
1st Apr 2020, 7:07 PM
Amxl Amixul
Amxl Amixul - avatar
0
Is not working your code Print(". Join(lst)) Is not executed is an error
1st Apr 2020, 6:35 PM
Amxl Amixul
Amxl Amixul - avatar
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")
2nd Apr 2020, 10:31 PM
maf
maf - avatar