You need to supply working snippets - missing imports
You cannot assume we know what they are
I think if you put print statements (as follows) in your code,
the error will stand out for you:
You cannot assume we know what they are
I think if you put print statements (as follows) in your code,
the error will stand out for you:
import random def rollDsix(): number = random.randint(1, 6) return number def generateAbilityScores(): i = 0 j = 0 scores = [] pool = [] while i < 6: while j < 4: roll = rollDsix() print('roll: {} scores: {}'.format(roll, scores)) scores.append(roll) j += 1 scores.sort() del scores[0] print('after delete scores: {}'.format(scores)) total = scores[0] + scores[1] + scores[2] pool.append(total) i += 1 generateAbilityScores()results:
Output:roll: 2 scores: []
roll: 2 scores: [2]
roll: 6 scores: [2, 2]
roll: 1 scores: [2, 2, 6]
after delete scores: [2, 2, 6]
after delete scores: [2, 6]
Traceback (most recent call last):
File "M:/python/m-p/p/play/nisc11.py", line 29, in <module>
generateAbilityScores()
File "M:/python/m-p/p/play/nisc11.py", line 25, in generateAbilityScores
total = scores[0] + scores[1] + scores[2]
IndexError: list index out of range