hackerrank-python
hackerrank-python copied to clipboard
Please teach a question, https://www.hackerrank.com/challenges/any-or-all
Please teach a question, any or all this question My code will waive a case if I remove list()
n = int(input())
def palindromic(n):
n = str(n)
if n == n[::-1]:
return True
return False
a = list(map(int, input().split()))
is_palindromic = [palindromic(x) for x in a]
is_positive = [x >= 0 for x in a]
print(all(is_positive) and any(is_palindromic))
Also the last line of code is written after yours but I don't understand why it is written this way, I can easily do without these two functions, but if I have to use them, I don't understand how to handle it