TypeError: 'int' object is unsubscriptable
You have to use str(pal) first, I guess.
Your core point is right, though; his clojure uses number->string + reverse, and the Python can too.
You have to use str(pal) first, I guess.
Your core point is right, though; his clojure uses number->string + reverse, and the Python can too.
print sum([x for x in range(1001) if x%3==0 and x%5==0)]
Quite a bit shorter than the clojure solution.
Further, their "isPalindrome" function involves a "digits_from_num" call, and is almost 10 lines in total. You could shorten that to one if you check pal == pal[::-1].
Essentially, the guy copied code from a website which wasn't really trying to show off how succinct python could be.