python二维列表问题
本帖最后由 wws741 于 2021-11-11 23:14 编辑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=="J" or card =="Q" or card=="K":
cardpoint = 0.5
elif card== "A":
cardpoint = 1
elif len(card)>2:
cardpoint = 10
else:
cardpoint = int(card)
return cardpoint
i=0
while i<num:
allplayers.append(CARDS)
allplayers=Computer_Point(CARDS)
del CARDS
i=i+1
print(allplayers)
最后allplayers.append(CARDS)
allplayers=Computer_Point(CARDS)这里怎么添加啊字符串类型无法修改,如何变成内嵌列表的形式
在Welcome_Players里面添加name的时候不要直接加,来一个tmp=[], tmp.append(name), 再把tmp添加到allplayers里面去,这样后面可以加 puremorning 发表于 2021-11-12 00:05
在Welcome_Players里面添加name的时候不要直接加,来一个tmp=[], tmp.append(name), 再把tmp添加到allplay ...
感谢,我直接添加
页:
[1]