Swap first and last digits

Run Settings
LanguagePython
Language Version
Run Command
import math def firstLastDigit(num:int)->int: #Determining number of digits present in the input noOfDigits = int(math.log10(num)) #Extracting lastdigit lastD=num%10 #Extracting firstDigit firstD=int(num/ pow(10, noOfDigits)) #print(num) # print(lastD, firstD) #Removed last digit and added the first didit to the last swapNum=int(num/10)*10+firstD #Adding the required part in the num required= (lastD-firstD)*(pow(10, noOfDigits)) #Adding the required in the swapNum swapNum=required+swapNum return swapNum print(firstLastDigit(7456542))
Editor Settings
Theme
Key bindings
Full width
Lines