Mailing List Archive

From geeksforgeeks.org, on converting the string created by the input() to an INT
We can first convert the string representation of float into float using float() function and then convert it into an integer using int().So, why can't a string of an integer be converted to an integer, via print(int(str('23.5')))???
Perplexed






| print(int(float('23.5'))) |



"When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."     
Isaiah 43:2
--
https://mail.python.org/mailman/listinfo/python-list
Re: From geeksforgeeks.org, on converting the string created by the input() to an INT [ In reply to ]
On Fri, 26 May 2023 at 09:58, Kevin M. Wilson via Python-list
<python-list@python.org> wrote:
>
> So, why can't a string of an integer be converted to an integer, via print(int(str('23.5')))???

23.5 is not an integer, so "23.5" is not the string of an integer.

ChrisA
--
https://mail.python.org/mailman/listinfo/python-list