Python Forum

Full Version: Python code not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
def main():
    print("Welcome to the rectangle calculator")
    print()

# Calls//
    input_rectangle1()
    input_rectangle2()
    area_1 = calc_area1(lenght1, width1)
    area_2 = calc_area2(length2, width2)
    display(area_1,area_2)

def input_rectangle1():
    print("Values of rectangle number one")
    print()
    length1 = float(input("Enter length of rectangle: "))
    width1 = float(input("Enter width of rectangle: "))
    return length1, width1

def input_rectangle2():
    print("Values of rectangle number two")
    print()
    length2 = float(input("Enter length of rectangle: "))
    width2 = float(input("Enter width of rectangle: "))
    return length2, width2

def calc_area1(length1, width1):
    area_1 = length1 * width1
    return area_1

def calc_area2(length2, width2):
    area_2 = length2 * width2
    return area_2

def display(area_1,area_2):
    if area_1 > area_2:
        print("The are of the rectangle number 1 is bigger")
    elif area_2 > area_1:
        print("The are of the rectangle number 2 is bigger")
    else:
        print("The areas are the same")

main()
Okay so basically that's for my homework, I already finished it as you guys can tell, but for some reason when I execute it it says this:

Error:
input_rectangle1() TypeError: input_rectangle1() missing 2 required positional arguments: 'length1' and 'width1'
so any feedback would be great, if you can explain me how to do it instead of giving me the answer I'd appreciate it, thanks and have a good day y'all!
I spot a spelling error in area_1 - looks like you spelled 'length' as 'lenght'... I don't know what that's worth but it's something!
Well thank you everyone but I just re-did the code a little bit more simpler. I realized that there was no need to return all those values if I just calculated the area inside the input definition of each rectangle. So that's what I did and now it works. Thanks!