-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJumbledWords
More file actions
63 lines (58 loc) · 1.78 KB
/
JumbledWords
File metadata and controls
63 lines (58 loc) · 1.78 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
60
61
62
63
import random
def choose():
words=['rainbow','computer','science','programming','summer','player','reverse','water','board','condition','mathematics']
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):
#computer's task
picked_word=choose()
#create question
qn=jumble(picked_word)
print("")
print (qn)
print("")
#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("")
print("Your score is : ",pp1)
else:
print("")
print("Better luck next time. I thought : ",picked_word)
c=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()
print("Your score is : ",pp2)
else:
print("Better luck next time.I thought : ",picked_word)
c=input("Press 1 to continue and 0 to quit : ")
if c==0:
thank(p1name,p2name,pp1,pp2)
break
turn=turn+1
play()