Last active
April 4, 2020 05:55
-
-
Save gautamrege/1583f228e81f1fe0a9132864e578b18c to your computer and use it in GitHub Desktop.
Hangman - Part 1 (working basic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
word := "elephant" | |
// lookup for entries made by the user. | |
entries := | |
// list of "_" corrosponding to the number of letters in the word. [ _ _ _ _ _ ] | |
placeholder := | |
for { | |
// evaluate a loss! If user guesses a wrong letter or the wrong word, they lose a chance. | |
// evaluate a win! | |
// Console display | |
fmt.Println("\n") | |
fmt.Println() // render the placeholder | |
fmt.Printf() // render the chances left | |
fmt.Printf() // show the letters or words guessed till now. | |
fmt.Printf("Guess a letter or the word: ") | |
// take the input | |
str := "" | |
fmt.Scanln(&str) | |
// compare and update entries, placeholder and chances. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment