I'm very new to python and am trying to create a basic I Ching Hexagram creation program, and I'm running into issues in my first function.
import random
def hexline():
#This flips three coins and produces a hexagram line
flip = random.randint(2,3)
res = flip+flip+flip
if res == 6:
print('-- --x')
elif res == 7:
print('-----')
elif res == 8:
print('-- --')
elif res == 9:
print('-----x')
When hexline()
is run, it only returns either -----x
or -- --x
(values of 9 or 6) indicating that randint(2,3)
is only making one random selection for the whole function (rather than 3 distinct random choices) and adding them together with res
. So res
is producing only 2+2+2
or 3+3+3
, rather than say 3+2+3
or 2+2+3
. How might I generate a random selection multiple times in this function, rather than only once? Thanks.