登录

有没有大佬来看一下为啥程序输出中对应的元素会大于定义的最大值?

import randomdict1={'2':2,"3":3,"4":4,'5':5,'6':6,"7":7,'8':8,'9':9,'10':10,"J":11,       "Q":12,"K":13,'A':14,'小王':15,'大王':16}dict2={'2':4,"3":4,"4":4,'5':4,'6':4,"7":4,'8':4,'9':4,'10':4,"J":4,       "Q":4,"K":4,'A':4,'小':1,'大':1}h=0deck=[]while h<17:       (a,b)=random.choice(list(dict2.items()))       try:           h=h+1           deck=deck+[a]           b=b-1           dict2[a]=b       except b<1:              h=hdeck=sorted(deck)print('',deck)

# Python
P粉278977405P粉27897740575 天前269 次浏览

全部回复(0) 我要回复

暂无回复
  • 取消回复发送