The Python Oracle

Combine multiple Booleans and Check if any are true in python

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Island

--

Chapters
00:00 Question
00:30 Accepted answer (Score 12)
00:42 Answer 2 (Score 0)
00:57 Thank you

--

Full question
https://stackoverflow.com/questions/1879...

Accepted answer links:
[any()]: http://docs.python.org/2/library/functio...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #boolean

#avk47



ACCEPTED ANSWER

Score 14


You can use any():

any([A, B, ...])



ANSWER 2

Score 0


If you want to check to see if ALL of the boolean variables are true, do the following:

 if all([length, zero_to_255, all_nums]) == True:
        print("Valid IP Address")