I need some help please, I have some code I've written which should manipulate a list using a function. The problem I'm having is keeping hold of this manipulated list to use in the main coding. For example, I created a list which contains names for 4 people queuing in line for tickets, I then input this list in a function to remove the 3rd in line. This will create a new list which I want to be able to manipulate outside of the function. Here is my code so far
def aLeave(aList,usrstr):
tempq = []
idx = 0
found = False
while idx < len(aList) and not found: #This section works out the index
if aList[idx] == usrstr: # of the user string that needs removed
found = True # from the queue list.
else:
idx = idx + 1
if found:
for i in range(len(aList)): #This sections takes the index previously
if i == idx: #found and uses it to create a new list
continue #without the element the user has requested to be removed
tempq.append(aList[i])
aList = tempq
print(aList)
return aList
aList = ["john","mark","pete","dave"]
aLeave(aList,input("what do you want to remove"))
print (aList)
Any help would be very much appreciated!
Thanks (The function is called 'aLeave')