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 122 views
1 answer 143 views
1 answer 153 views
1 answer 116 views
116 views asked Jan 11, 2024 by avibootz
1 answer 98 views
1 answer 105 views
105 views asked Jan 11, 2024 by avibootz
1 answer 125 views
125 views asked Jan 10, 2024 by avibootz
...