Confusion about Python Functions and Lists
<p>I am trying to create a function to remove an item from the passed list either by a specified index, or item passed. </p>

<p>If the user wishes to remove an item from the list using an index, the third argument passed will be <code>âindexâ</code>, if the user wishes to remove the first item found in the list using the item passed, the second argument will be <code>â{item}â</code> </p>

<p>For example, to remove the item at index 3 from a list, this would be the command <code>myFunction(myList,3,âindexâ)</code></p>

<p>I am quite confused about this function part.  I have written code that does exactly what the question seems to ask, but it does not use a function.  My code is below :</p>

<pre><code>mylist = ["one" , "two" ,"three" , "four" , "five"]
print "list is composed of: "+ str(mylist)
name = raw_input("Index of item to be removed. ex.  1")
name2 = raw_input('"item to be removed. ex. four')
name3 = int(name)
del mylist[name3]
mylist.remove(name2)
print mylist
</code></pre>

<p>It appears that I need to create a function to do this, and then pass in my list, the index/item, etc.)  but I am very lost on this part. </p>

<p>You really need to work on your questionsmithing skills. It's very difficult to understand what you are trying to accomplish. After making about half a dozen assumptions, I think this is what you are trying to do:</p>

<pre><code>def listRemover(mylist,index_or_name,mytype):
    if mytype == "index":
        del mylist[index_or_name]

    if mytype == "name":
        mylist.remove(index_or_name)
</code></pre>

<p>It's obvious though that there are some gaping holes in your basic knowledge of python. You need to study what a function is, why they are useful, and how to use them.</p>

python