[Solved] What is wrong with my code on calculating area of square/rectangle?


There are a couple of problems with your code.

1) The condition

if input in shape:

You never defined a variable “input”. Furthermore, I’m not real sure why you are checking a condition here anyways. If you’re trying to verify that shape is either a rectangle or square consider this code instead:

if shape in ["rectangle", "square"]:

2) The code

"Square, square"

does nothing, and is in fact invalid syntax.

3) The line

print(“The area of the given square is” + area)

is invalid string concatenation for the print function. (note you can concatenate this way OUTSIDE of the print function)
Use commas instead.

print("The area of the given square is", area)

6

solved What is wrong with my code on calculating area of square/rectangle?