class Settings: def __init__(self): self.__options = { "Configure Money": self.configureMoney, "Create Location": self.createLocation, "View Location": self.printLocation } def menu(self): while True: print("\n------------------------------------------\n") print("0)\tReturn to top menu") for i, option in enumerate(self.__options): print(f"{i+1})\t{option}") num = int(input("Input the number of the action to do: ")) if num == 0: break action = list(self.__options)[num - 1] self.__options[action]() def configureMoney(self): coins = {} print( """Input the different coins used along with their values in the form Name:Value eg. Gold Pieces:100 Enter an empty line to finish""") while line := input(): try: name, value = line.split(":") if name in coins: if input( f"Are you sure you want to overwrite the value of {name} from {coins[name]} to {value}? y/n " ).lower()[0] != "y": print("Overwrite aborted") continue value = int(value) except ValueError: print( "Invalid input. Ensure that it follows Name:Value format eg. Gold Pieces:100" ) else: coins[name] = value World.economy = World.Money(coins) print(World.economy)