We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Built-Ins
- Any or All
- Discussions
Any or All
Any or All
Sort by
recency
|
750 Discussions
|
Please Login in order to post a comment
I will just say that the explanation of problem wasn't coherent... like there was no mention of "ANY" number in list is palindrome but gave 5 is palindromic number... i wasted so much time clearing all TEST CASES when the answer was right in front of me
n1, n2=input(),input().split() print(all([int(i) > 0 for i in n2]) and any([j == j[::-1] for j in n2]))
if any([x for x in y] == [x for x in y][::-1] for y in int_list)
Explanation: x for x in y makes a list if digits from the y [::-1] reverses that list. We check the equality between the two to determine palidromality (a word I made up) for y in int_list breaks the int_list up into individual strings to check.
In thise case, just leave the input as a string for simplicity.
Here is HackerRank Any or All in Python solution - https://programmingoneonone.com/hackerrank-any-or-all-problem-solution-in-python.html