# Plz someone help

Having error with rectangle

``````print('''
1) square
2) rectangle
''')
b=float(input('enter: '))

if b==1:
c=int(input('enter length of square'))
print('area of square is:',c*c,'perimeter of square is:',c+c+c+c)

if b==2:
e=int(input('enter length of rectangle'))
print('area of rectangle is:',e*d,'perimeter of rectangle is:',e+d+e+d)

if b!=1 and b!=2:
print('invalid input')
``````

You have the wrong indentation level on some of your `print`s. Try this:

``````print('''
1) square
2) rectangle
''')
b=float(input('enter: '))

if b==1:
c=int(input('enter length of square'))
print('area of square is:',c*c,'perimeter of square is:',c+c+c+c)

if b==2:
e=int(input('enter length of rectangle'))
print('area of rectangle is:',e*d,'perimeter of rectangle is:',e+d+e+d)

if b!=1 and b!=2:
print('invalid input')
``````

Also, equality comparisons with floats are dangerous:

``````>>> 0.1 + 0.2 == 0.3
False
``````

Python is pretty good at doing what you would expect as long as you stick to integer values, but if you only need integers you should use ints instead of floats.

2 Likes

Thank you sir

How can I improve my indentation

Hereâ€™s a recent discussion related to indentation that you may find helpful: Indentation is important

In Python, code that belongs to a certain code block must share the same indentation level. In the code you included in your question, the print statements where you calculate area and circumference belong to the same code blocks as the code that collect the input variables, because those calculations depend on the input variables having already been defined.

To â€śimprove your indentationâ€ť, you need to reach a conceptual understanding of what constitutes a code block. There is no shortcut here, you just need to practice.

2 Likes