any() — Python Technical Interview Questions & Answers
any()
any()
- any() is built into Python. You do not import it. Freshers only need one honest call and the printed result — not a long definition.
- any() — output: True then False. any True if at least one item is true.
- Wrong type often raises TypeError. Empty values matter for bool/all/any. Don’t mix any up with a similar name (sorted vs sort, int vs float).
Technical Interview Tip: Call any() once and say what prints.
Code Examples for any()
Example
# any()
print(any([False, True]))
print(any([False, False]))
any() — output: True then False. any True if at least one item is true.
How to Explain any() to an Interviewer
Explain any() as if you are teaching a junior — definition, then one tiny script.
any() is built-in — no import. One call + exact output.
What does the example print, and why?
any() — output: True then False
What mistake do freshers make with any()?
Wrong type → TypeError.