Expressing infinity

var = int()
for var in range(var<0,var>=0):
    if var <= 1:
        var1 = -var-1+2-var == 6 
        print(var1)

1st Line: As you know, if I don’t define a value, an error message will be generated.

2nd Line: Attempting to express (-infinite to zero to + infinity)

Q: Since int() == 0 must be defined, the first and second lines conflict. How would you handle the situation? {“I know that Python doesn’t have an “infinity” concept.”}

What about:

>>> i=float("inf")
>>> i
inf
>>> 

1 Like

That is incorrect.

To be precise, you don’t have to define a value of var first to use it as a loop variable.

What are you trying to do here? Your code doesn’t make sense to me. You want to loop over every value from -infinity to +infinity. That’s going to take a long time.

Indeed, it doesn’t make sense. I was merely testing something.