-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
29 lines (27 loc) · 875 Bytes
/
code.py
File metadata and controls
29 lines (27 loc) · 875 Bytes
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
#Hangman game
import random
Friut_list=['apple','banana','orange','mango','strawberry','watermelon','kiwi','peach','pear','papaya','grapes','pineapple','guava','blueberry','blackberry','raspberry','apricot']
choice='Y'
while choice=='Y':
friut=random.choice(Friut_list)
lives=5; temp=[];word=[]
for i in fruit:
word.append(i)
temp.append('_')
while '_' in temp and lives!=0:
for i in temp:
print(i,end=' ')
print("\t Lives:",lives)
l=input("Guess a letter: ").lower()
if l in word:
for i in range(0,len(word)):
if word[i]==l:
temp[i]=l
else:
lives-=1
if lives==0:
print("GAME OVER!")
else:
print("YOU WIN!!!")
print("The word was ",fruit.upper())
choice=input("Play Again?(y/n) ").upper()