I have a list:
mylist = ['item 101', 'element 202', 'string 303', 'member 404']
I want to identify the three digits associated with 'item', but 'item' is not always in the same position, so I cannot use mylist[0]
.
I looked at the accepted answer in this StackOverflow post, and tried the following:
if any('item' in s for s in mylist):
print(s)
I get the following error:
NameError: name 's' is not defined
In researched that error, but I haven't been able to find any examples/solutions that fit this particular situation.