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 196 views
1 answer 215 views
1 answer 235 views
1 answer 177 views
177 views asked Jan 11, 2024 by avibootz
1 answer 175 views
1 answer 182 views
182 views asked Jan 11, 2024 by avibootz
1 answer 208 views
208 views asked Jan 10, 2024 by avibootz
...