本帖最后由 wws741 于 2021-11-11 23:14 编辑
[Python] 纯文本查看 复制代码 allplayers=[]
num=int(input('请输入玩家人数:'))
def Welcome_Players(n):
for i in range(n):
name=input('请输入玩家'+str(i+1)+'的姓名:')
print('欢迎玩家:'+name)
allplayers.append(name)
Welcome_Players(num)
import random
RANKS=("A","2","3","4","5","6","7","8","9",
"10","J","Q","K")
SUITS=('Z','X','C','V')
CARDS=[]
def Generate_Cards():
for i in RANKS:
for j in SUITS:
CARDS.append(i+j)
random.shuffle(CARDS)
print(CARDS)
Generate_Cards()
def Computer_Point(card):
if card[0]== "J" or card[0] == "Q" or card[0]== "K":
cardpoint = 0.5
elif card[0]== "A":
cardpoint = 1
elif len(card[0])>2:
cardpoint = 10
else:
cardpoint = int(card[0])
return cardpoint
i=0
while i<num:
allplayers[i][2].append(CARDS[0])
allplayers[i][3]=Computer_Point(CARDS[0])
del CARDS[0]
i=i+1
print(allplayers)
最后allplayers[2].append(CARDS[0])
allplayers[3]=Computer_Point(CARDS[0])这里怎么添加啊 字符串类型无法修改,如何变成内嵌列表的形式
|