repl.it
@VesterDE/

Hangman

Python (with Turtle)

No description

fork
loading
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import random


lives = 10
objects = ['fork','ball','puzzle','book','shirt','pillow','gluestick','scissors','pencil','sock','headphones','light','case','phone','television','wrist','year','python','number','computer','notebook','dinosaur','keyboard','potato','games','eraser','guard','blue','green','orange']

question = input("Hello, do you want to play a hangman? [Yes/No] ")

if question == "no":
  print("Ohh, well I hope you have a nice day, see you later.")
if question == "yes":
  print("OK the game has started.")

word = random.choice(objects)
guesses = []
while lives > 0:
  x = input("Have a guess: ")
  
  if guesses == 0: 
    print("You won!!!")
    if x not in word:
       lives = lives - 1
       print "You have",lives ,"guesses left"
       if lives == 0:
         print "You lost!!","The word was",( word )
      
  #Put that letter into a list of guesses
  missing = False
  guesses.append(x)
  for letter in word:
    if letter in guesses:
        print letter,
    else:
      print "_",
      missing = True
  
  print ""
  if not missing:
    print "You have won!"
    exit()
    
  






result
console
?