+ 3
I need help with a game that should be created with PYTHON.
Write a program to play the following game. There is a list of several country names and the program randomly picks one. The player then has to guess letters in the word one at a time. Before each guess the country name is displayed with correctly guessed letters filled in and the rest of the letters represented with dashes. For instance, if the country is Canada and the player has correctly guessed a, d, and n, the program would display -anada. The program should continue until the player either guesses all of the letters of the word or gets five letters wrong
7 odpowiedzi
+ 3
Interesting. How much of it have you completed?
+ 2
Chris Coder I imported the module (random) and I have been able to randomize the countries. Asked a user for his/her guess for 5 trials. Now the issue is replacing the letters that are not guessed with a dash (-)
+ 2
Well that is some progress. You can modify and learn from this code.
https://www.geeksforgeeks.org/JUMP_LINK__&&__python__&&__JUMP_LINK-program-for-word-guessing-game/
+ 2
Create a list from country name, use map() to change selective characters in the list (ones that are in user_guessed_letters string). Then glue the map() result back to string using string::join().
+ 2
Ipang I was wondering if map would work. I tried to program it and then I ended up having a similar code to geeksforgeeks.
+ 2
Chris
But why wouldn't map() work? I tried it using the OP's example - country: "Canada" and got "-anada" in the end.
+ 2
Thanks to everyone for the help. It was really helpful. Currently studying the code.