How to Convert Variables

104 9
    • 1). Open a text editor or interpreter for your language.

    • 2). In the interpreter create a variable and assign a string to it. In Python, this looks like:

      test = '5.5'

    • 3). Use a type cast to convert the variable to another type. Changing the string to a floating point number is the most sensible type cast. In Python:

      float(test)

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.