Guys I am trying t write this script that finds the age of a daughter through palindromes.
Here is the question:
Recently I had a visit with my mom and we realized that the two digits that make
up my age when reversed resulted in her age. For example, if she’s 73, I’m 37.
“When I got home I figured out that the digits of our ages have been reversible six times so far. So the question is, how old am I now?
This is what I got....the program runs, but it doesn't return anything. It doesn't even close it self. :(
def palindrome_ages(mom, daughter): daughter_rev = int(str(daughter)[::-1]) palindrome_num = 0 while daughter_rev != mom: daughter = daughter + 1 if daughter_rev == mom: palindrome_num = palindrome_num + 1 if palindrome_num == 6: return str(daughter) def main(): """ main function """ mom = 36 daughter = 0 print palindrome_ages(mom, daughter) return 0 if __name__ == "__main__": main()
Edited 6 Years Ago by HoneyBadger: n/a