How to truncate a number from left in Python

1 Answer

0 votes
import math

def truncate_left( num) :
    total = int(math.log10(num))

    first_digit = int(num / math.pow(10, total))
    
    return num - first_digit * int(math.pow(10, total))
    
num = 7483

print(truncate_left(num))




''' 
run:

483

'''

 



answered Jan 11, 2024 by avibootz

Related questions

1 answer 115 views
1 answer 139 views
1 answer 148 views
1 answer 112 views
112 views asked Jan 11, 2024 by avibootz
1 answer 94 views
1 answer 99 views
99 views asked Jan 11, 2024 by avibootz
1 answer 118 views
118 views asked Jan 10, 2024 by avibootz
...