【发布时间】:2019-06-13 20:19:17
【问题描述】:
我正在尝试找到“rollList”的最大值,但我尝试过的所有方法都不起作用。我的编码不是很好,老师给我的指导也不是很清楚。我还必须将每个玩家的“rollList”重置为空,我很困惑。请有人帮忙。
随机导入 班级球员: def __init__(self,name): self.name = 名称 自我骰子 = [] def __str__(self): 返回 self.name def roll_Dice(self): rollDice = random.randint(1, 6) 返回掷骰子 回合 = 1 滚动列表 = [] 新玩家 = [] newplayer.append(播放器(“猫:”)) newplayer.append(播放器(“狗:”)) newplayer.append(播放器(“蜥蜴:”)) newplayer.append(Player("FISH:")) 对于范围(1,4)内的回合: 打印(” - - - - - - - - -”) 打印(“轮”+ str(轮)) 对于新玩家中的 p: 打印(p) 对于范围内的 x(4 轮): rollDice = random.randint(1, 6) rollList.append(rollDice) 打印(滚动列表) 最大弹出(滚动列表) 打印(滚动列表) rollList.clear() len(滚动列表)【问题讨论】:
-
您希望
max.pop(rollList)行做什么? -
你能说明你是如何设置你使用的所有变量的吗?
-
newlst.append(max(rollList)).