I defined a function that allows me to find a specific character in a parameter and returns all subsequent characters. Example:
def function1(parameter1):
variable1 = parameter1[parameter1.find("&"):]
variable1 = variable1[1:]
return variable1
This seems to execute without issue. However, I am having a problem with my second function, which allows me to pass a list through the first function, compare, and return True or False
def function2(list, variable1):
for parameter1 in list:
parameter1 = function1(list)
if variable1 == parameter1:
return True
else:
return False
Then, I define my list and variable1 to for function2 and print:
list = ["abc&123", "def&456", "ghi&789"]
variable1 = "123"
print function2(list,variable1)
I cannot seem to figure out what I've been doing wrong. Something seems to be off wither how I am passing through the list, resulting in errors regarding split or find (I've tried both), and/or my comparison of Variable1 and parameter1. I'm sure there's a small issue here that I keep getting tripped up on, but for the life of me I cannot figure it out.
Aucun commentaire:
Enregistrer un commentaire