Alex Rivera | Logout

AND/OR in Python?

Asked 2012-04-13T23:51:29.207
40

I know that the and and or expressions exist in python, but is there any and/or expression? Or some way to combine them in order to produce the same effect as a and/or expression?

my code looks something like this:

if input=="a":        
    if "a" or "á" or "à" or "ã" or "â" in someList:            
        someList.remove("a") or someList.remove("á") or someList.remove("à") or someList.remove("ã") or someList.remove("â")

with this, I mean that if the user inputs "a" and any type of "a" is included in a previously defined list, can I have all the types of "a" removed from a given list?

python tells me that there is a problem in:

someList.remove("a") or someList.remove("á") or someList.remove("à") or someList.remove("ã") or someList.remove("â")

he tells me: ValueError: list.remove(x): x not in list

Edit
Report

1 Answer

5

Are you looking for...

a if b else c

Or perhaps you misunderstand Python's or? True or True is True.

answered 2012-04-13T23:53:31.853

Your Answer