0

I am making a questioning program with python 3, I use this code

print ('how old are you?')
age = input ('age :')
if age < 18): print('Okay')

when i run it, there are a message said

if age < (18):
^
IndentationError: unexpected indent

what should i do?

Matt
  • 45,022
  • 8
  • 78
  • 119
Redsec
  • 13
  • 4
  • 1
    Possible duplicate of [Unexpected Indent error in Python](https://stackoverflow.com/questions/4263485/unexpected-indent-error-in-python) – Hussein El Feky Aug 27 '17 at 01:27

3 Answers3

1

if age < 18) should be if (int(age) < 18)

0

If takes an expression leads to boolean value between ()

your code missed (, it should be:

if (int(age) < 18)
Fady Saad
  • 1,169
  • 8
  • 13
0

It appears that the if keyword may be indented when you don't need it to be. On StackOverflow - the code may look correct, but on you editor, it is possible that it isn't. In Python, indentation matters. It's how the program knows when one block of code is done OR if a block of code is associated with another part.