#!/usr/bin/env python3

FILEPATH = "database.dat"
FILE_LOADED = False

def print_menu():
    menu_format = "{0:2}->{1:5}"
    print("{text:-^25}".format(text="pyrtemonnaie"))
    print(menu_format.format("1", "set filepath"))
    print(menu_format.format("2", "load file"))
    if(FILE_LOADED):
        print(menu_format.format("3", "dump file"))
        print(menu_format.format("4", "edit value"))
        print(menu_format.format("5", "save file"))
    print()
    print(menu_format.format("q", "quit pyrtemonnaie"))

print_menu()
#!/usr/bin/env python3

import operator

FILEPATH = "database.dat"
FILE_LOADED = False
MENU_FORMAT = "{0:2}->{1:5}"
MENU_OPTIONS = {
                "1": "set filepath",
                "2": "load file",
                "3": "dump file",
                "4": "edit value",
                "5": "save file",
                "q": "quit pyrtemonnaie"
}

def print_menu():
    print("{text:-^25}".format(text="pyrtemonnaie"))

    for option in sorted(MENU_OPTIONS, key=operator.itemgetter(0)):
        print(MENU_FORMAT.format(option, MENU_OPTIONS[option]))

def get_menu_input():
    choice = str(input("-> "))
    if(choice in MENU_OPTIONS.keys()):
        return choice
    else:
        return -1

print_menu()
choice = get_menu_input()
move menu_options to dict and iterate add function get_menu_input