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.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Any or All
You are viewing a single comment's thread. Return to all comments →
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.