Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Check if a string represents a float in Python
- def is_float(a_string):
- try:
- float(a_string)
- return True
- except ValueError:
- return False
- print(is_float('2.2.2'))
- print(is_float('2.123'))
- # Returns:
- # False
- # True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement