[Tutor] changing list index start

Rance Hall ranceh at gmail.com
Fri Sep 10 23:36:39 CEST 2010


I'm using the following function style I found on the net to create
menus for a command line python script:

def mainmenu():
    # the main menu
    todolist()
    mainmenuoptions = ['Clients','Jobs','Billing','Quotes','To Do
Items','Employee','Exit']
    mainmenucalls = [clientsmenu, jobsmenu, billingmenu, quotesmenu,
todomenu, empmenu, quit]
    for i,option in enumerate(mainmenuoptions):
        print('%s. %s' % (i, option))
    mainchoice = int(input('\nYour Choice? '))
    clearscreen(osname)
    mainmenucalls[mainchoice]()
    return

It works well, but the first item is the list is item 0.  This is
normal in most computing situations, but because this index is part of
the output It would be nice if the first item in the list is item 1.

php provided a way to change this, but I can find no documentation
that says python can do this as well.

I'm sure that python can do this, but I'm unable to find a definitive
answer with google.

Would someone please enlighten me?


More information about the Tutor mailing list