-
Notifications
You must be signed in to change notification settings - Fork 0
/
python-project.py
82 lines (40 loc) · 1.37 KB
/
python-project.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
50
51
52
53
54
55
56
57
58
59
60
61
import random
movie_list= ["Unborn", "Avengers","Avatar","Inception", "Joker","Godfather","Terminator","Frozen","Aladdin"]
print("\n this is a guessing game, more or less like hangman.\n",
"you will be given a movie name(English) with vowels only.\n",
"your guess limit is 10, and your guess input should be 1 consonant only")
n= random.choice(movie_list)
def guess(n):
x= n.upper()
guess_count=0
guess_limit=10
a=""
for i in x:
if i not in 'AEIOU':
a= a + "_"
else:
a= a + i
print(a)
lis=[]
while guess_count!=guess_limit:
l=input("enter a letter to guess the movie further:\n")
new_a=""
lis.append(l.upper())
for let in x:
if let in 'AEIOU':
new_a+=let
elif let in lis:
new_a+=let
else:
new_a= new_a+"_"
print(new_a)
guess_count+=1
print("you have ",guess_limit-guess_count, "guesses left")
if new_a==x:
print("congrats! you got the movie!")
break
if guess_count==guess_limit:
print("Oops! you are out of guesses")
y="hope you enjoyed playing!"
return y
print(guess(n))