def ext_num(n): lst = [] while n >= 1: lst.append(n%10) n = (n-n%10)/10 return lst def is_pal(n): num_list = ext_num(n) num_len = len(num_list) if num_len % 2 != 0: for l in range((num_len-1)/2): if num_list[l] != num_list[-l-1]: return False break else: return True else: for m in range(num_len/2): if num_list[m] != num_list[-m-1]: return False break else: return True for x in range(999,100,-1): for y in range(999,100,-1): if is_pal(x*y): print "big is: " + str(x*y) + ", by: " + str(x) +", and" + str(y) break
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question