'EOFError: EOF when reading a line

I am trying to define a function to make the perimeter of a rectangle. Here is the code:

width = input()
height = input()
def rectanglePerimeter(width, height):
   return ((width + height)*2)
print(rectanglePerimeter(width, height))

I think I haven't left any arguments opened or anything like that.



Solution 1:[1]

Use a try / except block to get rid of the EOF error.

try:
    width = input()
    height = input()
    def rectanglePerimeter(width, height):
       return ((width + height)*2)
    print(rectanglePerimeter(width, height))
except EOFError as e:
    print(end="")

Solution 2:[2]

convert your inputs to ints:

width = int(input())
height = int(input())

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tripleee
Solution 2 astrognocci