If value like element in list then print that element in list.
val = 'https://www.google.com/search?q=google'
elements = ['google.com', 'bing.com', 'yahoo.com']
I want the result google.com
.
My code:
if val in elements:
print(elements)
I know print(elements)
will print all the elements in the list. But can I just print the one element it matches to?
I want to do val like in elements
print the element it matches to
if val in element: ...