-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (34 loc) · 872 Bytes
/
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
import random #importing necessary module
name= input("Enter your name:")
print("Goodluck "+name+"!")
file = open("names.txt")
names = file.readlines()
name = random.choice(names)
name = name.lower()
word = str(name).strip('\n')
name = str(name).strip('\r')
print("Guess the Characters: ")
guesses = str()
if ' ' in name:
guesses += ' '
turns = 6
while turns >0:
failed = 0
for char in name:
if char in guesses:
print(char,end=' ')
else :
print ('_',end=' ')
failed += 1
if failed == 0:
print("\nYou Win!")
exit()
guess = input("\n\nGuess a character")
guesses += guess
if guess not in name:
turns -= 1
print ("Wrong")
print("You Have " + str(turns)+ "more guesses" )
if turns ==0:
print("You Lose")
print("The movie was :",name)