At the moment my code has multiple if statements that are similar (see below) and i was wondering if there was a way to make a variable or something that can change based on what comes out of the random.choice?
So if it landed on druid instead of checking if the result was barbarian then moving onto the next block of code it would just take druid from the random.choice output and change the import for a single block of code accordingly
sorry if this is worded badly, it's hard for me to convey what i mean, i can elaborate if needed
def randclass():
return random.choice(class_dict[chosenrace])
if randclass() == "Barbarian":
print(chosenrace, "Barbarian")
if fullconfirm == "yes":
from barbarianfullbuild import barbarianrandsubclass, barbarianrandbackground, barbarianskills
print(barbarianrandsubclass)
print(barbarianrandbackground)
print(barbarianskills)
if randclass() == "Druid":
print(chosenrace, "Druid")
if fullconfirm == "yes":
from druidfullbuild import druidrandsubclass, druidrandbackground, druidskills
print(druidrandsubclass)
print(druidrandbackground)
print(druidskills)