How to check if a string has a numeric value in Python

2 Answers

0 votes
s = "739"

if s.isdigit():
    print("true")
else:
    print("false")



'''
run:

true

'''

 



answered Aug 30, 2018 by avibootz
edited May 18, 2024 by avibootz
0 votes
s = "1py34 thon70"
print(s.isdigit())
 
s = "1253"
print(s.isdigit())
 
s = "1 34"
print(s.isdigit())

 
 
'''
run:
 
False
True
False
 
'''

 



answered May 18, 2024 by avibootz

Related questions

...