Python any() and all() function

Author: Al-mamun Sarkar Date: 2020-03-26 14:34:07

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