
Zac H. answered 05/28/19
A Data Scientist with the world leader in Education Services
Its good practice to use type(object) - type() is a built in, and no installation is required.
Once you are sure which type you are handling, you can convert types using int(), float() and str().
For example:
my_number = '545.2222' # string
my_float = float(my_number) # returns 545.2222 as float format
Second Example:
my_number = '31' # string
my_integer = int(my_number) # returns 31 as int format
Third Example:
my_integer = 31 # int
my_string = str(my_integer) # returns '31' as str format
Take care!
zac