I'm simply trying to make a code that generates dice (in python).
Here's the code:
import random
class Dice:
def _init_(self, number_dice):
self._dice = [6] * number_dice
def roll_dice(self):
for d in range(len(self._dice)):
self._dice[d] = random.randit(1, 6)
self._dice.sort()
def print_roll(self):
length = len(self._dice)
print(str(lenth) + "dice:" + str(self._dice))
my_dice = Dice(2)
my_dice.roll_dice()
my_dice.print_roll()
The compiler says something about line 18.
I'm new to programming so anything helps =]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…