From 215361e4d9c9f4bde2f87057e0b0e947865a11a9 Mon Sep 17 00:00:00 2001 From: Zachary Watts Date: Sat, 18 Apr 2026 00:53:57 -0400 Subject: [PATCH] looking to the get() method some --- main.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index ec02234..7ec9b68 100755 --- a/main.py +++ b/main.py @@ -3,12 +3,13 @@ import random class PlayerCharacter: def __init__(self, attributes={}) -> None: - self.strength = roll_dice(3,6) if not attributes else attributes['strength'] - self.intelligence = roll_dice(3,6) if not attributes else attributes['intelligence'] - self.wisdom = roll_dice(3,6) if not attributes else attributes['wisdom'] - self.dexterity = roll_dice(3,6) if not attributes else attributes['dexterity'] - self.constitution = roll_dice(3,6) if not attributes else attributes['constitution'] - self.charisma = roll_dice(3,6) if not attributes else attributes['charisma'] + # using a get() method to pull an attribute else use a default value + self.strength = attributes.get('strength', roll_dice(3,6)) + self.intelligence = attributes.get('intelligence', roll_dice(3,6)) + self.wisdom = attributes.get('wisdom', roll_dice(3,6)) + self.dexterity = attributes.get('dexterity', roll_dice(3,6)) + self.constitution = attributes.get('constitution', roll_dice(3,6)) + self.charisma = attributes.get('charisma', roll_dice(3,6)) def class_selector(self): # take the 4 primary attribtues