hackerrank-python icon indicating copy to clipboard operation
hackerrank-python copied to clipboard

Please teach a question, https://www.hackerrank.com/challenges/any-or-all

Open n-WN opened this issue 3 years ago • 0 comments

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

n-WN avatar Jan 16 '23 12:01 n-WN