I’m trying to check whether a user-inputted string is contained in a list of other strings AND any permutation of those strings, separated by a “*”.
In other words, here’s the code I have so far:
user_string=raw_input("Please supply a string")
viable_entries=['this', 'that', 'something else']
if user_string in viable_entries:
print "here I'd move on with my script"
I’d also want to print “here I’d move on with my script” if user_string = “something else*this” or “this*that”, etc.
Is there an easy, pythonic way to do this?
You can split the input and use
set.issubset:Note that this gives
Trueeven if an entry is repeated ("this*this"). If you want to prevent the user providing repeated entries you can uselen(set):