def getInt():
while True:
width = int(input("Enter width (1 - 60):"))
if width > 1 and width < 60:
break
else:
print("Please enter a valid input")
while True:
height = int(input("Enter width (1 - 20):"))
if height > 1 and height < 20:
break
else:
print("Please enter a valid input")
return width, height
def calcPerimeter(width, height):
perimeter = (2 * (width + height))
return perimeter
def calcArea(width, height):
area = width * height
return area
def main():
print('Results: {}'.format(getInt()))
print('The perimeter is {}' .format(calcPerimeter(width, height)))
print('The area is {}' .format(calcArea(width, height)))
main()
When I run, it says:
Traceback (most recent call last):
main()
print('The perimeter is {}' .format(calcPerimeter(width, height)))
NameError: name 'width' is not defined