adding accessing and deleting items from a python list
<p>Learning lists and arrays and I am not sure where I went wrong with this program. Keep in mind I am still new to python. Unsure if i am doing it right. Ive read a few tutorials and maybe Im not grasping list and arrays. Ive got it to where you can type a name but it doesnt transfer to a list and then i get list is empty constantly as well as other errors under other functions in the code.</p>

<pre><code> def display_menu():
    print("")
    print("1. Roster ")
    print("2. Add")
    print("3. Remove ")
    print("4. Edit ")
    print("9. Exit ")
    print("")
    return int(input("Selection&gt; "))


def printmembers():
        if namelist &gt; 0:
            print(namelist)
        else:
            print("List is empty")


def append(name):
    pass


def addmember():
    name = input("Type in a name to add: ")
    append(name)

def remove():
    pass

def removemember():
    m = input("Enter Member name to delete:")
    if m in namelist:
        remove(m)
    else:
        print(m, "was not found")

def index():
    pass

def editmember():
    old_name = input("What would you like to change?")
    if old_name in namelist:
        item_number = namelist.index(old_name)
        new_name = input("What is the new name? ")
        namelist[item_number] = new_name
    else:
        print(old_name, 'was not found')


print("Welcome to the Team Manager")

namelist = 0

menu_item = display_menu()

while menu_item != 9:
    if menu_item == 1:
        printmembers()
    elif menu_item == 2:
        addmember()
    elif menu_item == 3:
        removemember()
    elif menu_item == 4:
        editmember()
    menu_item = display_menu()
print("Exiting Program...")
</code></pre>

<p>For starting out, you've got the right ideas and you're making good progress. The main problem is how you defined <code>namelist = 0</code>, making it a number. Instead, <code>namelist</code> needs to be an actual <code>list</code> for you to add or append anything to it. Also, you're <code>append()</code> method is not necessary since once you define <code>namelist</code> as a <code>list</code>, you can use the built-in <code>list.append()</code> method, without having to write your own method.
So here are a few suggestions/corrections, which once you have the basis working correctly, you should be able to work out the rest of the bug fixes and logic.</p>

<ol>
<li><p>Since you don't have any main() method, you can define <code>namelist</code> on
the <strong>first line of code</strong>, before any other code, so that it is
referenced in each method:<br>
<code>namelist = [] # an empty list</code></p></li>
<li><p>Change <code>addmember()</code> method to: </p>

<p><code>def addmember():
    name = raw_input("Type in a name to add: ")
    namelist.append(name)</code></p></li>
<li><p>Since <code>namelist</code> is a list, we can use the <code>built-in</code> <code>len()</code> method on <code>nameslist</code> to check if it's empty when printing out its contents (if any):</p>

<p><code>def printmembers():
        if len(namelist) &gt; 0: # Get the length of the list
            print(namelist)
        else:
            print("List is empty")</code></p></li>
</ol>

<p>Now that the <code>Add()</code> menu option is working for adding a name to the <code>namelist</code>, you should be able to implement removing, and editing names to the list using similar logic.</p>

python