Playing with Python, and to test my skills, I wanted to build a Python Script that is centered on the rules for creating a character in D&D 5E. Script so far:
for x in range (1):
strength.append(random.randint(3,18))
str_score = strength
Ability_Score_Modifiers = {'1' : '-5',
'2' : '-4',
'3' : '-4',
'4' : '-3',
'5' : '-3',
'6' : '-2',
'7' : '-2',
'8' : '-1',
'9' : '-1',
'10' : '0',
'11' : '0',
'12' : '+1',
'13' : '+1',
'14' : '+2',
'15' : '+2',
'16' : '+3',
'17' : '+3',
'18' : '+4',
'19' : '+4',
'20' : '+5',
'21' : '+5',
'22' : '+6',
'23' : '+6',
'24' : '+7',
'25' : '+7',
'26' : '+8',
'27' : '+8',
'28' : '+9',
'29' : '+9',
'30' : '+10'}
for keys in Ability_Score_Modifiers.keys() and str_score:
if Ability_Score_Modifiers.keys([str_score]) == Ability_Score_Modifiers.keys():
print ('True', value)
else:
pass
The problem I am having is getting the Script to look at the value generated by the skill and check it against my dictionary and then return the value for the respective key that matches the number returned for the skill.
This is a snippet the source is here 5E Character creator - python edition
I've been at this for about a day and a half and I'm coming up blank. Of course, I'm using pythonfiddle to practice while at work so I am not getting my logic errors.
Thanks