I am moving on to Python and am still relatively new to the pythonic approach. I want to write a function that takes a string and a list and returns true if all the elements in the list are found in the string.
It seemed pretty simple. However, I come across this. The code looks something like this:
def myfun(str,list): for a in list: if not a in str: return False return True
Example : myfun('tomato',['t','o','m','a']) should return true myfun('potato',['t','o','m','a']) should return false myfun('tomato',['t','o','m']) should return true
Also, I was hoping someone could suggest a possible regex approach here. I'm also trying to trick them.
source share