I was trying to create a function with no experience in Python, it was an exercise I found on a website and this was the exercise:
"Timmy & Sarah think they are in love, but around where they live, they will only know once they pick a flower each. If one of the flowers has an even number of petals and the other has an odd number of petals it means they are in love.
Write a function that will take the number of petals of each flower and return true if they are in love and false if they aren't."
I tried everything and went through tons of errors but at the end it didn't work
flower1 = input("Number of petals in the first flower: ")
flower2 = input("Number of petals in the second flower: ")
def lovefunc( flower1, flower2 ):
flower1 = int(flower1)
flower2 = int(flower2)
lovetest = flower1 + flower2
lovetest /= 2
if isinstance(lovetest, float): lovetest = "yes"
else: lovetest = "no"
for lovetest in "yes": print ("You are in love")
else: print ("You aren't in love")
print(lovefunc(flower1, flower2))
And it doesn't matter the input this is always the output:
You are in love You are in love You are in love You aren't in love None
What did I do wrong?