I want to be able to search a string for characters in different lists.
For example:
list1=['a']
list2=['b']
If a user enters in 'a' for example. Python should print 'list1' and for 'b' list2.
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.
def char_search(input_str):
for char in input_str:
if char in list1:
print("lower")
if char in list2:
print("Upper")
I want to be able to combine the two if statements, and only print something if both conditions are True.
Aucun commentaire:
Enregistrer un commentaire