Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python code not working
#1
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!
Reply
#2
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!
Reply
#3
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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  New to Python - Not sure why this code isn't working - Any help appreciated TheGreatNinx 4 954 Jul-22-2023, 10:21 PM
Last Post: Pedroski55
  code not working when executed from flask app ThomasDC 1 877 Jul-18-2023, 07:16 AM
Last Post: ThomasDC
  New to python/coding Need help on Understanding why this code isn't working. Thanks! mat3372 8 1,740 May-09-2023, 08:47 AM
Last Post: buran
  I am new to python and Could someone please explain how this below code is working? kartheekdas 2 1,003 Dec-19-2022, 05:24 PM
Last Post: kartheekdas
Exclamation My code is not working as I expected and I don't know why! Marinho 4 1,072 Oct-13-2022, 08:09 PM
Last Post: deanhystad
  My Code isn't working... End3r 4 1,922 Mar-21-2022, 10:12 AM
Last Post: End3r
  I don't undestand why my code isn't working. RuyCab 2 1,979 Jun-17-2021, 03:06 PM
Last Post: RuyCab
  code is not working , can anybody help? RandomPerson69 4 2,900 Mar-22-2021, 04:24 PM
Last Post: deanhystad
  Short code for EventGhost not working Patricia 8 3,666 Feb-09-2021, 07:49 PM
Last Post: Patricia
  Code no longer working yk303 14 10,099 Dec-21-2020, 10:58 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020