Python any() and all() function

Python any() and all() function

Instructor-svgAl-Mamun Sarkar
Mar 26 , 2020

Python any() and all() function. The following code shows how to solve the HackerRank Any or All Python collections problem. 

Code:

N, n = int(input()), input().split()

print(all([int(i)>0 for i in n]) and any([j == j[::-1] for j in n]))

 

Test Input:

5
12 9 61 5 14 

Test Output:

True

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram