I am new to Python. I am writing a string function to check if a certain string contains certain multiple values. Is there a syntax in python to allow me to do something like this:
def strParse(str):
a = 't'
b = 'br'
c = 'ht'
if a in str AND b in str AND c in str:
print('Ok!')
(The part I am unsure about is having multiple if statements on line.) Thanks!
Almost correct, just make the
andlower-case:Doesn’t cause problems in this case, but you should avoid using variable-names that are also built-in functions (
stris a builtin function/type)If you have more values, you can do the same thing more tidily like so: