Reputation: 5
I created that y list that equals ['jan', 'feb', 'mar', '451'] I tried to convert the type of y[3] into a float, but when I printed the type of y[3] it appeared to be a string somehow.
What is the problem?
>>>x = "jan feb mar 451"
...y = x.split()
...float(y[3])
...type(y[3])
str
Upvotes: 0
Views: 98
Reputation: 4366
You need to assign result of float convertion with e.g. z = float(y[3])
or if you want to replace your string value with float you could do it with y[3]=float(y[3])
.
Upvotes: 1