用户:
江子奇查看:128 回复:0 评论:0 创建时间:2019-06-03T11:32:29
【作品展示】

【作品介绍】
出现同样的数字怎么用花色判断大小
【作品源代码】
import random
suits = ["方块","梅花","红桃","黑桃"]
faces = ["2","3","4","5","6","7","8","9","10","J","Q","K","A"]
keep_going = True
while keep_going:
my_face = random.choice(faces)
my_suit = random.choice(suits)
your_face = random.choice(faces)
your_suit = random.choice(suits)
print("我的数字是"+my_suit+my_face )
print("电脑的数字是" + your_suit+your_face)
if faces.index(my_face) > faces.index(your_face):
print("我赢!")
elif faces.index(my_face) < faces.index(your_face):
print("电脑赢!")
else:
print("平局!")
answer = input("Hit [Enter] to keep going, and key to exit: ")
keep_going = (answer == "")
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn