How to delete the first digit from a number in Python

2 Answers

0 votes
import math

n = 87315

s = str(n)
s = s[1:]

n = int(s)     
         
print(n)



'''
run:

7315

'''

 



answered Jun 4, 2020 by avibootz
0 votes
import math

n = 87315

print(int(math.log10(n)))
print(int(math.pow(10, int(math.log10(n)))))
         
n = n % int(math.pow(10, int(math.log10(n))));
print(n)



'''
run:

4
10000
7315

'''

 



answered Jun 4, 2020 by avibootz

Related questions

1 answer 159 views
1 answer 162 views
1 answer 140 views
1 answer 161 views
4 answers 276 views
2 answers 297 views
2 answers 235 views
...