Python Forum

Full Version: Create a dynamic Menu from a editable Dictionary.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to create a dynamic menu system that will produce menu items based on what items are specified in the _number_ranges dictionary.

I would the result to be

Please Select a Range:
1 - 549 StKilda Rd
2 - Mulgrave
3 - Rhodes
4 - Not Defined Number

I would also like to be able to add to the ranges and have that create the corresponding menu items.



# Define Site Ranges Dictionary
_number_ranges = {
    "549StKilda": {
        'start': 61392697000,
        'end': 61392697999,
        'name': "549 StKilda Rd"
    },
    "Mulgrave": {
        'start': 61385849100,
        'end': 61385849199,
        'name': "Mulgrave"
    },
    "Rhodes": {
        'start': 61298169000,
        'end': 61298169999,
        'name': "Rhodes"
    },
    "Not Defined Number": {
        'start': 0,
        'end': 99999999999,
        'name': "NON Number"
    },
 
def find_available_n():
    for num_range in _number_ranges:
        print(num_range)
        #Ask for Choice
        choose_range = input("Please Select Range: ")
        return choose_range
you might want to take a look at curses : https://docs.python.org/3/library/curses.html