-1
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")

GETTING SYNTAX ISSUES. need to get program to run through all these commands and struggling to get it to work. Professor said something about conversions from integers and strings but I just don't get it. PLEASE HELP

Harsha Biyani
  • 7,049
  • 9
  • 37
  • 61

1 Answers1

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")
Jay Shankar Gupta
  • 5,918
  • 1
  • 10
  • 27