Create a function that attempts to convert a string to a float and returns the float value. Use exception handling to return None if the conversion fails.
Example 1:
Input: "3.14"
Output: 3.14
Example 2:
Input: "not a number"
Output: None
Use the built-in float() function to convert the string to a float. Be sure to wrap the operation in a try/except block to handle potential exceptions.
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.