我需要以下方面的帮助:
编写一个函数(main),它将要求用户输入起始和结束数字范围(包括)。用while循环数数。只有当数字是回文时才将其加到总数中(调用isNumberPalindrome)。加上数字后打印总数
到目前为止,我对这个(主)函数的理解是。。。在def main():
start = int(input("Enter a number to start counting at:"))
end = int(input("Enter a number to end counting at:"))
while start <= end:
print(start)
start = start + 1
这是我的函数(isNumberPalindrome)的功能。在
^{pr2}$
到目前为止,我的(main)函数要求用户输入(起始和结束数字),并使用while循环对其进行计数。我不知道要在(main)函数的代码中添加什么来实现“只有当数字是回文时才将数字加到总数中”(调用isNumberPalindrome)。将数字相加后打印总数。“
谢谢你的帮助。在
到目前为止,提供给我的代码就是这样。在Enter a number to start counting at:1
Enter a number to end counting at:6
1
Traceback (most recent call last):
File "C:/Users/Tyler/Desktop/AWDADXC.py", line 38, in
main()
File "C:/Users/Tyler/Desktop/AWDADXC.py", line 33, in main
if isNumberPalindrome(start):
File "C:/Users/Tyler/Desktop/AWDADXC.py", line 18, in isNumberPalindrome
if len(s) < 1:
TypeError: object of type 'int' has no len()
有人知道怎么回事吗?在