数字回文检查器
Palindrome Checker for numbers
我目前正在尝试做作业。我的回文检查器需要一些帮助。这是我到目前为止所做的
begin = int(input('Enter begin: '))
end = int(input('Enter end: '))
palindromes = 0
#Add your code here. You will want to start with a "for x in range" style loop.
for x in range(begin, end, -1):
print('There are', palindromes, 'palindrome(s) between', begin, 'and', end)
这不是函数。请帮忙。
检查数字是否为回文的最简单方法可能是将其视为字符串,翻转它,然后检查翻转后的字符串是否与原始字符串相同。从那以后,它只是一个循环,计算你遇到了多少:
begin = int(input('Enter begin: '))
end = int(input('Enter end: '))
palindromes = 0
#Add your code here. You will want to start with a "for x in range" style loop.
for x in range(begin, end):
if str(x) == str(x)[::-1]:
palindromes += 1
print('There are', palindromes, 'palindrome(s) between', begin, 'and', end)
我目前正在尝试做作业。我的回文检查器需要一些帮助。这是我到目前为止所做的
begin = int(input('Enter begin: '))
end = int(input('Enter end: '))
palindromes = 0
#Add your code here. You will want to start with a "for x in range" style loop.
for x in range(begin, end, -1):
print('There are', palindromes, 'palindrome(s) between', begin, 'and', end)
这不是函数。请帮忙。
检查数字是否为回文的最简单方法可能是将其视为字符串,翻转它,然后检查翻转后的字符串是否与原始字符串相同。从那以后,它只是一个循环,计算你遇到了多少:
begin = int(input('Enter begin: '))
end = int(input('Enter end: '))
palindromes = 0
#Add your code here. You will want to start with a "for x in range" style loop.
for x in range(begin, end):
if str(x) == str(x)[::-1]:
palindromes += 1
print('There are', palindromes, 'palindrome(s) between', begin, 'and', end)