Q:

Multiple selections from a list using Python

I have created a big list of server names. I want to present this as a menu to the user  and create a new list that will contain only the names/multiple choices selected by the user. 
BigList = ['server1','server2','server3','server4']
while (i < len(BigList)):
    i =+ 1
print "%d. %s Return to main menu" % (i+1,BigList)
menu = raw_input("Enter the selection with comma:")
menu = menu.split(",")
return menu

When the user selects multiple choices from menu, the list I get is a list of numbers and not the actual server names to return. Also there is no error handling such as if the number is valid from menu or not.
Any help is appreciated, I am new to Python, trying to learn more. 

A:

Seeing as you havent had an answer yet, I will just give you an example of what i think you might be trying to achieve:
BigList = ['server1','server2','server3','server4']

# here we use enumerate to generate the index i for the current item
# we pass in a temp list with an extra entry concatenated so that we
# dont need to duplicate the print expression
input_list = BigList + ['Return to main menu']
for i, item in enumerate(input_list):
    print "%d. %s" % (i, item)

# get user input
menu_input = raw_input("Enter the selection with comma:")

# the list of selection indexes 
menu_selection_indexes = []

# sanitize and store the indexes from user input string
for i in menu_input.split(','):
    # could print/throw errors on bad input
    # here we choose to discard bad list items silently
    try:
            # convert the string e.g. "2" into an integer type
            # so that we can use it to index into our menu list
        val = int(i.strip())
    except ValueError, ve:
            # some strings (e.g. "a") cannot be converted to an integer
            # a ValueError exception is thrown if this is attempted
            # we catch this exception and just ignore this value,
            # skipping this value continuing on with the next for-loop item
        continue
    # ignore indexes that exceeed the acceptable input list size
    if val > len(input_list):
        continue
    menu_selection_indexes.append(val)

# print indexes
print menu_selection_indexes

# if the last possible input index was chosen, we return to menu
if len(BigList) in menu_selection_indexes:
    if not len(menu_selection_indexes) == 1:
        print "warning: mixed commands"
    print "will return to main menu"

else:
    # list of items selected, using list comprehensions
    menu_selection_names = [input_list[i] for i in menu_selection_indexes]

    # print names
    print menu_selection_names

