-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jumble Words.py
67 lines (54 loc) · 1.89 KB
/
Jumble Words.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
62
63
64
65
66
67
import random
def play():
words = ["Hello","Good","Morning","Keep","Smiling"] #you can add more words here
p1name = input("\nPlayer1, Enter your name: ")
p2name = input("\nPlayer2, Enter your name: ")
pp1 = 0
pp2 = 0
turn = 0
while(1):
#for player1
print("\n")
print(p2name,"picked a word")
picked_word = random.choice(words)
random_word = random.sample(picked_word, len(picked_word))
qn = ''.join(random_word)
print(qn,"\n")
print(p1name,"your turn!!")
ans = input("Whats on " + p2name + " mind?: ").lower()
if ans == picked_word.lower():
pp1 += 1
print("\nThat's correct answer...")
print(p1name,"scored: ",pp1)
else:
print("Btter luck next time, but",p2name,"thought:",picked_word)
# for player2
print("\n")
print(p1name,"picked a word")
picked_word = random.choice(words)
random_word = random.sample(picked_word, len(picked_word))
qn = ''.join(random_word)
print(qn,"\n")
print(p2name,"your turn!!")
ans = input("Whats on " + p1name + " mind?: ").lower()
if ans == picked_word.lower():
pp2 += 1
print("\nThat's correct answer...")
print(p2name,"scored: ",pp2)
else:
print("Btter luck next time, but",p1name,"thought:",picked_word)
print("\n\n")
c1 = input(p1name +", you want to continue the game?(y/n): ").lower()
c2 = input(p2name +", you want to continue the game?(y/n): ").lower()
if c1 == "y" and c2 == "y":
continue
else:
break
if pp1 == pp2 :
print("\n\tBoth won!!")
elif pp1 > pp2:
print("\n\tCongrats!!",p1name,"won")
else:
print("\n\tCongrats!!",p2name,"won")
if __name__ == "__main__":
play()