Set-up
I have the following dictionary,
d={'City':['Paris', 'Berlin','Rome', 'London']}
and the following one-element list,
address=['Bedford Road, London NW7']
Problem
I want to check if one of the cities is in the address.
Tried so far
(1)
for x in d['City']:
if x in address:
print('yes')
else:
print('no')
only prints no
.
(2)
for x in d['City']:
r = re.compile(x)
newlist = list(filter(r.match, address))
gives a TypeError: 'str' object is not callable
. Got this one from this answer which seems to be what should solve this, but the error doesn't help.
How do I go about?