+ 1
Basic function for dice simulator doesn't work, unsure why
import random def dice_roll (): x = int (input ("How many sides would you like the die to have? ")) y = int (input ("How many would you like to roll? ")) z = int (input ("Is there a modifier you would like applied? ")) if x != int: dice_roll () if y != int: dice_roll () if z != int: dice_roll () print (random.randint (1,x) * y + z) dice_roll()
3 Réponses
+ 3
I guess your "if" statements are trying to check types for x, y and z. If so, it should be
if type(x) != int
Doing that also for y and z should work.
+ 2
separate note, but statistically this is wrong. the odds of rolling 3 d6 and getting 18 aren't the same as rolling 3 d6 and getting 9. you should use a for loop to roll new dice instead of assuming all of them are the same. the more dice the closer to average your results should be
+ 1
ahh, thank you, I knew for a fact that was the issue , but I didn't know how to properly check for a TYPE of data, I just assumed this would work. thank you!