I need to check whether a string input is a valid number in Python, but I’m unsure of the best way to do it. I know I can try to convert the string to a number and catch exceptions, but is there a more efficient way to check if a string can be converted to an integer or float?
Would love to hear your thoughts on the most Pythonic way to do this.