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 248 views
1 answer 264 views
1 answer 247 views
1 answer 258 views
4 answers 479 views
2 answers 426 views
2 answers 362 views
...