def func(num): i=0 new_num=0 num_copy=num while num_copy>0: num_copy=num_copy//10 i+=1 while num>0: new_num+=10**(i-1)*(num%10) num=num//10 i-=1 return new_num print(func(983839))