vendredi 26 novembre 2021

Trying to write a function that receives a number argument and check and print if the number is positive, negative, or zero (Python 3) [duplicate]

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
> 

Aucun commentaire:

Enregistrer un commentaire