-
Notifications
You must be signed in to change notification settings - Fork 0
/
cardgame.py
59 lines (55 loc) · 1.48 KB
/
cardgame.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
import random
num={
1:1,
2:2,
3:3,
4:4,
5:5,
6:6,
7:7,
8:8,
9:9,
10:10,
11:"J",
12:"Q",
13:"K"
}
# print(random.choice(list(num.values())))
sign=["spades","diamonds","clover","hearts"]
computernumber=random.choice(list(num.keys()))
# print(num.values())
computersign=random.choice(sign)
usernumber=random.choice(list(num.keys()))
usersign=random.choice(sign)
# print(computernumber)
# print(usernumber)
if computernumber>usernumber:
print("Computer: %s%s"%(num[computernumber],computersign))
print("User: %s%s"%(num[usernumber],usersign))
print("you lose")
elif computernumber<usernumber:
print("Computer: %s%s"%(num[computernumber],computersign))
print("User: %s%s"%(num[usernumber],usersign))
print("you win")
elif computernumber==usernumber:
print("tie")
print("Computer: %s%s"%(random.choice(list(num.values())),computersign))
print("User: %s%s"%(random.choice(list(num.values())),usersign))
else:
print("error")
# number=[1,2,3,4,5,6,7,8,9,10,"J","Q","K"]
# print(random.choice(number),random.choice(sign))
# computernumber=random.choice(number)
# computersign=random.choice(sign)
# usernumber=random.choice(number)
# usersign=random.choice(sign)
# def ask():
# userinput=input("Press the spacebar once to play")
# return userinput
# def play(computernumber,computersign,usersign,userinput,usernumber):
# print(computernumber,computersign)
# if
# if userinput=" ":
# play()
# else:
# ask()