Darien Springer Darien Springer - 2 years ago 138
Python Question

python if else function not working

I am trying to make it so that when I call the function "vote" that a conditional statement will execute and either return True or False. When I run it Python tells me there is no output. I put inputs in the function I called so I am confused. What am I doing incorrectly? Here is my code:

def vote(vote_one, vote_two, vote_three):
if (vote_one == vote_two):
return True
elif (vote_one == vote_three):
return True
elif (vote_two == vote_three):
return True
return False

vote(1, 2, 1)

This has been marked as a duplicate. Although the other user ultimately had the same problem, I do not believe we were asking the same question. I was asking why there was no "output" and the other user was asking what the difference between "return" and the print function. To me we had the same misunderstanding but does that mean it's the same question? Because you would answer both questions using different vocabulary.

Answer Source

It's because you aren't actually outputting anything. When you call vote(), a result is returned (True or False), but you aren't using the result. You could do

result = vote(1, 2, 1)


print(vote(1, 2, 1))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download