-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathcode.py
More file actions
38 lines (37 loc) · 1.01 KB
/
code.py
File metadata and controls
38 lines (37 loc) · 1.01 KB
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
word=input("Enter word: ")
hint=input("Enter hint for word: ")
n=len(word)
dict1={}
for letter in word:
if letter==' ':
continue
if letter in dict1:
dict1[letter]+=1
else:
dict1[letter]=1
sorted_dict=dict(sorted(dict1.items()))
print(sorted_dict)
print("The letters in the word along with their frequencies are:")
print(sorted_dict)
print("You get five wrong guesses to guess the word")
print("Good luck!")
for it in range(1,6):
flag1=0
guess=(input(f"guess {it}:"))
if guess==word:
print("Congratulations you guessed the word!")
break
for i in range(0,it):
print("💔",end=" ")
for i in range(0,5-it):
print("❤️",end=" ")
print()
if it==3:
print("Only 2 lives left, do you want a hint?")
ans=input("Enter yes/no:")
if(ans.lower()=="yes"):
print("Hint:",hint)
else:
print("Ok, you may continue.")
if it==5:
print(f"The word was {word}. Better luck next time.")