I am defining a function called is_equal. If the two numbers are equal, the code prints 'equal'. If they do not match, it prints nothing. The numbers are hard-coded in; so there is no input from the keyboard. I have tried moving the 'print(equal) underneath the def is_equal, but it still doesn't print anything; although the numbers match. Any suggestions?
def is_equal(num1, num2):
if num == 4:
num1 = int(num1)
num2 = int(num2)
is_equal(4,4)
print(equal)
``
Simply do,
def is_equal(num1, num2):
if int(num1) == int(num2):
print("Numbers are equal")
Anything you put under the if
condition will be executed when the numbers (num1
and num2
) have same value.
The other things in your function doesn't make sense. You can remove them as they are not required for the task you have mentioned in your question.