I have a list of strings:
my_list = ["John 123", "Johnny 232", "Jane 344"]
What I want to do is check if a string in my_list does not contain a variable exactly, but anything else in the string after the variable doesn't matter.
For example if I have var = "John"
, my_list[0] would return True, but both my_list[1] and my_list[2] would return False. I need to check the entire list or until one returns True, whichever comes first.
EDIT: Here's a snippet of the actual code I'm working on:
names = []
rank, male, female = info
for name in names:
if male not in names:
names.append(male + " " + rank + '\n')
if female not in names:
names.append(female + " " + rank + '\n')
info gets pulled from a html file, but for example will be something like ['123', 'John', 'Jane']
, a number followed by a male name and a female name. My problem as of now is obviously the if statements will always be True, resulting in duplicate entries besides for the number.