所以这是我的作业,但我真的不知道如何做一步。在main()
函数的最后一步,我想根据 isPalindrome 函数返回的值报告数字是否为回文。我真的不知道如何做到这一点,所以请大家帮忙。谢谢
这是我到目前为止得到的。
# Write code that reverses the number and then returns the reversed number.
def reverse(number):
reverse=0
while number>0:
reverse = reverse * 10 + number % 10
number=number//10
return reverse
#Write code that call the reverse function,processes the value returned by the reverse function and returns True if the number is a palindrome.It will return False if number is not a palindrome.
def isPalindrome(number):
if number == reverse:
return True
else:
return False
#Write code to prompt the user to enter an integer, calls the isPalindrome function and (depending on the value returned by the isPalindrome function) reports if the number is a palindrome or not.
def main():
number=int(input("enter number: "))
main()
所以我基本上停留在最后一部分