import random\nrandom.seed()\n\ndef rolldice(numdice):\n result=0\n rolls=[]\n for n in range(1,numdice):\n roll=random.randint(1,6)\n rolls.append(roll)\n if result < roll:\n result = roll\n elif roll==6:\n result+=1\n return [result,rolls]
Is giving me this error:
>>> dice.rolldice(4)\nTraceback (most recent call last):\n File "<interactive input>", line 1, in ?\n File "dice.py", line 7, in rolldice\n for n in range(1,numdice):\nNameError: global name 'randint' is not defined
Yes, I know that randint is not defined somehow, but that's in a module that comes by default with Python, not in something I control. If I understand properly, importing random should result in all random functions being initialized, no?