Area of a rectangle [SPOILER] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Area of a rectangle [SPOILER]

Hey everyone, so I just finished this exercise and wanted to test the code in the playground. Here's the code: length = int(input()) width = int(input()) def area(length, width): #your code goes here print(length * width) if length == width: print('Square') area(length, width) What blows my mind is the fact that on the exercise there's no problems but in the playground I get this error: File "file0.py", line 6 if length == width: ^ IndentationError: unindent does not match any outer indentation level. Any lead about it? Thanks!

6th Apr 2021, 4:55 PM
Da Silva Miguel
Da Silva Miguel - avatar
5 Answers
+ 2
Learn code indentation, what it is, how it is done correctly. https://code.sololearn.com/cT5BRIbkia21/?ref=app
6th Apr 2021, 5:08 PM
Ipang
+ 1
Thanks for the link Ipang! It's very interesting and gonna keep it. I compared my code with the examples and didn't seen any problem. So what I did, was erasing all spaces and tabs and tabbed everything (not the def line) and tabbed 2 times the 'print('Square')' and it worked. Can't tell why but worked. :) Thanks again for the help! :)
6th Apr 2021, 5:27 PM
Da Silva Miguel
Da Silva Miguel - avatar
+ 1
My pleasure, When such thing happens, but indents doesn't seem to be having problem visually, then we look for indents inconsistency. That is, where a code was indented with different character, spaces & tabs mixed together. We should just be more consistent with the character ussd for indenting code. This unfortunately, only affects Python because indents are means of code structuring.
6th Apr 2021, 9:39 PM
Ipang
0
IMaybe you should make fhe indent on your if statement a little more pronounced. It is so small it does not really look like an indent. Does that fix it?
10th Jul 2021, 1:31 AM
Chris
Chris - avatar
0
length =int(input()) width=int(input()) def area(x,y): print(x*y) if x==y: print("Square") area(length,width)
26th Feb 2022, 9:33 AM
Chintala Santhosh