Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining if the number is odd or even [closed]

Tags:

python

I am putting this in,


def check(digit):
     if digit % 2 == 0:
         print("Even number")

check()

and in return i am getting an error which says,

 Traceback (most recent call last):
 File "<pyshell#9>", line 1, in <module>
 check()
 TypeError: check() missing 1 required positional argument: 'digit'

Can anyone help me figure what am i doing wrong?

like image 517
Palermox Avatar asked Dec 01 '25 01:12

Palermox


1 Answers

You are not calling your function check with any arguments. You also have to indent your if statement.

def check(digit):
     if digit % 2 == 0:
         print("Even number")
     else:
         print("Odd number")

check(3) # Prints "Odd number"
check(4) # Prints "Even number"
like image 70
Ffisegydd Avatar answered Dec 03 '25 13:12

Ffisegydd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!