swapping first and last digits of a number :Python Program
Here is the program for swapping first and last digits of a number in Python programming language
program code :
n=int(input("number:"))
last=n%10
n=int(n/10)
n1=str(n)
n2=str(1)
n6=str(1)
for i in range(len(n1)-1):
n2=n2+str(0)
n6=n6+str(0)
n6=int(n6)
n2=int(n2)
n5=int(n/n6)
n3=n%n2
print(n5)
n4=str(last)+str(n3)+str(n5)
print(int(n4))
output :
enter number :284517
784512
happy coding.
comment what you need.
Comments
Post a Comment