Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # hangman
- #import random number function
- import random
- #import time function
- import time
- #prints to user
- print "Welcome to hangman!\n"
- time.sleep(0.5)
- print "Start guessing...\n"
- time.sleep(0.5)
- #word generator
- def word_gen(min_length=5, filename="words.txt"):
- min_line_length = min_length + 1
- with open(filename) as wordlist:
- words = [line for line in wordlist if len(line) >= min_line_length]
- word = random.choice(words).lower
- print word
- #number of guesses
- guesses = 0
- #number of turns
- turns = 10
- while turns > 0:
- for char in word:
- print char
- print "------------\n| |\n|\n|\n|\n|\n|\n|\n|\n|\n------------\n| |\n------------\n"
- word_gen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement