This is for an assignment. We have to translate some provided java code into Python. Most of it was simple however the last bit is messing with my head. The whole code is a menu with one of the options being 'To display Palindromes up to 1000'. They're wanting a translation rather than a re-write - I'm sure there is a million ways to do it. What am I getting wrong in the method part ...
def isPalindrome(n):
str_n = str(n)
reverse = ""
for i in range(len(str_n)-1, -1, -1):
reverse = reverse + str_n[i]
result = str_n == reverse
return result
there is some other menu code here ......
elif option == 3:
print("PALINDROMES")
for i in range(0, 1000):
if isPalindrome(i):
print(i)
break