-
Notifications
You must be signed in to change notification settings - Fork 25
/
JUMBLE WORDS USING PYTHON
53 lines (51 loc) · 1.4 KB
/
JUMBLE WORDS USING PYTHON
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
import random
def choose():
words=["rainbow","computer","science","programming","mathematics","player","condition","reverse","water","board"]
pick=random.choice(words)
return pick
def jumble(word):
jumbled="".join(random.sample(word,len(word)))
return jumbled
def thank(p1n,p2n,p1,p2):
print(p1n,"your score is :",p1)
print(p2n,"your score is :",p2)
print("thanks for playing")
print("have a nice day")
def play():
p1name=input("Player 1,please enter your name:")
p2name=input("player 2,please enter your name::")
pp1=0
pp2=0
turn=0
while(1):
picked_word=choose()
qn=jumble(picked_word)
print (qn)
#player 1
if (turn%2==0):
print(p1name,"your turn.")
ans=input("what is on my mind?")
if ans==picked_word:
pp1=pp1+1
print("your score is:",pp1)
else:
print("better luck next time.i thought:",picked_word)
c=int(input("press 1 to continue and 0 to quit:"))
if c==0:
thank(p1name,p2name,pp1,pp2)
break
#player 2
else:
print(p2name,"your turn.")
ans=input("what is on my mind?")
if ans==picked_word:
pp2=pp2+1
print("your score is:",pp2)
else:
print("better luck next time.i thought:",picked_word)
c=int(input("press 1 to continue and 0 to quit:"))
if c==0:
thank(p1name,p2name,pp1,pp2)
break;
turn=turn+1
play()