forked from nishant-Tiwari24/python-foundation-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJumbledWords.py
More file actions
59 lines (48 loc) · 1.56 KB
/
JumbledWords.py
File metadata and controls
59 lines (48 loc) · 1.56 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import random
def choose():
words = ["apple", "banana", "cherry", "date", "grape", "kiwi", "lemon", "mango", "orange", "pear"]
pick = random.choice(words)
return pick
def jumble(word):
jumbled = "".join(random.sample(word,len(word)))
return jumbled
def thank(player1,player2,pp1,pp2):
print(player1," score is ",pp1)
print(player2," score is ",pp2)
print('Thanks for playing')
def play():
player1 = input('Enter the name of first player: ')
player2 = input('Enter the name of second player: ')
pp1 = 0
pp2 = 0
turn = 0
pickedWord = choose()
qn = jumble(pickedWord)
print(qn)
while(1):
if turn%2 == 0:
print(player1," your chance")
ans = input('What is in your mind?\n')
if ans == pickedWord:
pp1 = pp1 + 1
print('Your score is ',pp1)
else:
print('Better luck next time')
c = int(input('Choose 1 to continue and 0 to quit '))
if c==0:
thank(player1,player2,pp1,pp2)
break
else:
print(player1," your chance")
ans = input('What is in your mind?')
if(ans == pickedWord):
pp1 = pp1 + 1
print('Your score is ',pp1)
else:
print('Better luck next time',pickedWord)
c = int(input('Choose 1 to continue and 0 to quit'))
if c==0:
thank(player1,player2,pp1,pp2)
break
turn=turn+1
play()