-1

Here is my code to check is the number is positive, negative or zero.

x = input("Enter a number to check if it is positive, negative or zero.")
def function():
    if x == 0:
    print("The number is zero.")
    
    elif x > 0: 
    print("The number is positive.")
    
    elif x < 0:
    print("The number is negative.")

Here is the error I get

File "<string>", line 4
    print("The number is zero.")
    ^
IndentationError: expected an indented block
> 
  • Indentation is very important in Python. Have you written any Python code before? If not, I recommend you learn the basic syntax first. –  Nov 26 '21 at 18:31
  • ... This is NOT a function receiving an integer argument ... – Patrick Artner Nov 26 '21 at 18:32
  • Thanks, I just learned not to ignore the error feedbacks I get. – Inverted_ Spaces Nov 26 '21 at 18:59
  • I fixed the code def fun(): x =input("Enter a number to check if it is positive,negative or zero:") if int(x) == 0: print("The number is zero.") elif int(x) > 0: print("The number is positive.") elif int(x) < 0: print("The number is negative.") fun() – Inverted_ Spaces Nov 26 '21 at 19:00

1 Answers1

0

Indentation is very important in Python:

if x == 0:
    print("The number is zero.")