Message from Python discussions
December 2018
— In both cases a
is a str
In the first one, a
is '5'
, it can be converted to int
in the second one, a
is '5.5'
, it can't be converted to int
, you have to cast it to float
first
— Rookie
You can think of it like this
when a = 5.5
You cannot simply say
B = int(a)
Because that would be like saying
B = int(5.5)
And int cannot take a float value thus this will throw you an error
— Look at it rookie you can cast to float
in both cases
— Have you noticed the difference?
— So 5.5 a not incorrect form? a float 5.5 can and a str 5.5 cant. is there any chance the python can tell the dot "."from str? maybe python sentenced the dot to be and only can be a full stop?
— a
is a str... you can't cast a str
without knowing what it contains, see this:
— Thx cj,you blow my mind.i think you help me find the right answer. stupid python haha
— Python is not stupid 🤣
— This error drive me out of sleep all night. its past 4 am in china. now i could relax and have a nice dream. thx everyone.
— Yawn. That again.
— Hello friends