To summarize what was said in the comments
It is impossible to represent infinity as an integer in Python. This is consistent with the behavior of many other languages. However, due to the dynamic typing system of Python, you can use float('inf')instead of an integer, and it will behave as you expected.
"double" , Python , float, , Java, float double . Python , , Java.