# Use the function float() to turn a string into a float string = '123.456' number = float(string) number # Output: # 123.456
Here is what the above code is Doing:
1. We create a string variable called string and set it equal to ‘123.456’.
2. We create a float variable called number and set it equal to the float() function.
3. We pass the string variable to the float() function.
4. The float() function returns the string as a float.
5. We print the float variable to the console.