python verifier qu 27un string est un chiffre

Solutions on MaxInterview for python verifier qu 27un string est un chiffre by the best coders in the world

showing results for - "python verifier qu 27un string est un chiffre"
Brenton
23 Feb 2019
1var = input()
2try:
3    var = int(var)
4except ValueError:
5    pass
6
Kayla
04 Aug 2019
1def is_number(s):
2    try:
3        float(s)
4        return True
5    except ValueError:
6        return False
7
8print(is_number(3)) # True
9print(is_number("ok")) # False
10print(is_number("32")) # True
11