int_one =input("Please enter a three-digit number thats first number is greater than last ")
int_one_swap = (int_one[-1]+int_one[1:-1]+int_one[0])
print (int_one_swap)
print (int(int_one) - int(int_one_swap))
math_one = (int(int_one)-int(int_one_swap))
print (math_one)
int_two_swap = (int(math_one[-1]+int(math_one[1:-1])+ int(math_one[0]))
print (int_two_swap)
final = (int_two_swap + math_one)
print (final)
if final == 1089:
print ("Your result is 1089")
else:
print ("Your result is not 1089 so your first and last digits must have differed by less than 2")
获取语法问题。 需要让程序运行所有这些命令并努力使其工作。教授说了一些关于整数和字符串转换的内容,但我还是没有得到它。请帮助
答案 0 :(得分:0)
int_one =input("Please enter a three-digit number thats first number is greater than last ")
int_one_swap = (int_one[-1]+int_one[1:-1]+int_one[0])
print (int_one_swap)
print (int(int_one) - int(int_one_swap))
math_one = (int(int_one)-int(int_one_swap))
print (math_one)
int_two_swap = int(int(str(math_one)[-1])+int(str(math_one)[1:-1])+ int(str(math_one)[0]))
print (int_two_swap)
final = (int_two_swap + math_one)
print (final)
if final == 1089:
print ("Your result is 1089")
else:
print ("Your result is not 1089 so your first and last digits must have differed by less than 2")