Detect if characters in string are in list1 or list2
<p>I want to be able to search a string for characters in different lists.</p>

<pre><code>For example:

list1=['a']
list2=['b']
</code></pre>

<p>If a user enters in 'a' for example. Python should print 'list1'
and for 'b' list2.</p>

<p>Right now i'm trying to use this function to query the list, but I have to query each list in two separate if statements, like this.</p>

<pre><code>def char_search(input_str):
    for char in input_str:
        if char in list1:
            print("lower")
        if char in list2:
            print("Upper")
</code></pre>

<p>I want to be able to combine the two if statements, and only print something if both conditions are True.</p>

<p><strong>Update</strong> Thanks for the prompt replies, however I need to combine if statements.</p>

<p>Example: Only print a response if a string contains characters from both list 1 and 2</p>

<p>Input='a' should not work, nor Input='b', but if user enters 'ab', the repsonse should be something like 'both lists have been matched'. Sorry if I didn't make that clear at the start. The above code was only meant to represent the two different if statements.</p>

<pre><code>choice = input("choose a letter")

if choice in list1:
    print(list1)
elif choice in list2:
    print(list2)
else:
    print("choice not listed")
</code></pre>

python list if-statement