The last index in your [2:4]
slice is not inclusive. This means slicing your string like that will result in '06'
.
If you want '068'
, you need to take the [2:5]
slice.
Then, converting to a float using float('068')
should give you 68.0
.
I don't get why slicing your string using the [2:5]
slice would return '068;'
. I've tried it in my interpreter and it really only returns '068'
.
Are you sure that you are using the right slices?