As you learned in the Data Types & Variable Assignment section, there are multiple data types to meet your data needs in Python. If your data needs change or if your data was imported incorrectly, you can change data types.
In this section, you will learn how to:
Copy the following code on the left in your IDE to execute the process shown in the image on the right.
Checking Data Types | type(variable)
ic = "34"
print(type(ic))
Converting to String | str(variable)
ic = 34
print(ic)
ic = str(ic)
print(type(ic))
Converting to Integer | int(variable)
ic = "34"
print(ic)
ic = int(ic)
print(type(ic))
Converting to Float | float(variable)
ic = "34"
print(ic)
ic = float(ic)
print(type(ic))
Converting from String to List | list.split("separator")
lis = "Tulane University Libraries"
lis= lis.split(" ")
print(type(lis))
lis2 = "she, has, a, new, major"
lis2 = lis2.split(",")
print(type(lis2))