pops up an error
Traceback (most recent call last):
File "script.py", line 2, in <module>
y1 = int(input())
EOFError: EOF when reading a line
Who will tell you how it should be and why?
Answer 1, authority 100%
EOFError
occurs when CTRL-D is pressed.
By the way, it is better to do so that the input contains text and you should output not the text “y2”, but the variable y2:
y1 = int(input("Entery1: "))
r = int(input("Enterr: "))
if abs(y1) <= abs(r) and ((y1 > 0 and r < 0) or (y1 < 0 and r > 0)):
if r > 0: y2 = y1 + r + 1
elif r < 0:
y2 = y1 + r - 1
else:
y2 = y1 + r
print(y2)
You can also try except
on input
so that only numbers can be entered