2018-12-13叢曉強作業
阿新 • • 發佈:2018-12-13
實現發牌器(排中不包含大小鬼),共4個玩家,沒人13張牌
import random zhangsan = [] lisi = [] wangwu = [] liuer = [] puke = [] l = ["A","2","3","4","5","6","7","8","9","10","J","Q","K"] w = ["紅桃","方片","梅花","黑桃"] for i in w: for s in l: y = "{}{}".format(i,s) puke.append(y) print("一共有這些{}撲克".format(puke))class Puke: def zhangsan(self): for i in range(13): a = random.choice(puke) zhangsan.append(a) puke.pop(puke.index(a)) print("zhangsan的撲克為{}".format(zhangsan)) def lisi(self): for i in range(13): a = random.choice(puke) lisi.append(a) puke.pop(puke.index(a))print("lisi撲克為{}".format(lisi)) def wangwu(self): for i in range(13): a = random.choice(puke) wangwu.append(a) puke.pop(puke.index(a)) print("wangwu撲克為{}".format(wangwu)) def liuer(self): for i in range(13): a = random.choice(puke) liuer.append(a) puke.pop(puke.index(a))print("liuer撲克為{}".format(liuer)) ren= Puke() ren.wangwu() ren.lisi() ren.liuer() ren.zhangsan()