Trying to get the area of a rectangle using python 3.7

Instructions: This function to calculate the area of a rectangle is not very readable. Can you refactor it, and then call the function to calculate the area with base of 5 and height of 6? Tip: a function that calculates the area of a rectangle should probably be called rectangle_area, and if it's receiving base

Instructions: This function to calculate the area of a rectangle is not very readable. Can you refactor it, and then call the function to calculate the area with base of 5 and height of 6? Tip: a function that calculates the area of a rectangle should probably be called rectangle_area, and if it's receiving base and height, that's what the parameters should be called.

My attempt:

def area_rectangle (base, height): area_rectangle (5, 6) area = (base*height) print("The area is " + str(area)) 

Error message:

Here is your output:

Not quite. Remember to use meaningful names for functions and variables, and to call the function correctly.

Question: What am I doing incorrectly, to rectify this issue?

1

1 Answer

I'm pretty sure you meant:

def area_rectangle (base, height): area = (base * height) print("The area is " + str(area)) area_rectangle(5, 6) 

The reason your code didn't work is because it will become infinite recursion. The function would call itself and call itself infinite times until the RecursionError comes.

So you would need to call it outside the function.

0

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobXJoaGaFc3%2BOramyoZ6cerW7jKCcrWWknbJurdGemGanlmKubr7EnKuappehsm7B0qKloGWgrsGpu81mamZv

 Share!