why is the following?
>int(2)
>>2
>
int('2')
>>2
>
int(2.6)
>>2
>
int('2.6')
>>error
I cannot understand why the error in the last part?
why is the following?
>int(2)
>>2
>
int('2')
>>2
>
int(2.6)
>>2
>
int('2.6')
>>error
I cannot understand why the error in the last part?
It's a string containing a float: in Python 3 (not sure about 2) it must be a string of an integer, such as the other cases.
In case you want to read it as an int (of course rounding down or up) you must do something like int(float(mystring))