How to get the third digit of a number in Python

1 Answer

0 votes
n = 1795

third = str(n)[2] 
 
print(third)
print(type(third))

x = int(str(n)[2])

print(x)
print(type(x))


     
'''
run:
     
9
<class 'str'>
9
<class 'int'>

'''
       

 



answered Jun 1, 2020 by avibootz

Related questions

1 answer 147 views
1 answer 144 views
2 answers 200 views
200 views asked May 29, 2020 by avibootz
1 answer 114 views
...