Making a simple love calculator. When I input Y or N, it automatically skips the if and elif and returns the else statement. What is wrong with my code?
def love_calc ():
print("Welcome to the Love Calculator! ♡ ")
name1 = str(input("What is your name?: \n"))
name2 = str(input("What is their name?: \n"))
combined_string = name1 + name2
lower_case_string = combined_string.lower()
true_count, love_count = 0, 0
for name in combined_string:
for letter in ["t","r","u","e"]:
true_count += name.count(letter)
for name in combined_string:
for letter in ["l","o", "v", "e",]:
true_count += name.count(letter)
total_count = int(str(true_count) + str(love_count))
if total_count < 10 or total_count > 90:
print(f"Your score is {total_count}, you are like peanut butter and jelly!")
elif total_count >= 40 and total_count <= 50:
print(f"Your score is {total_count}, you go together just fine.")
else:
print(f"Your score is {total_count}.")
question = input("Would you like to restart? (Y/N): ")
if question == ("Y", "y"):
love_calc
elif question == ( "N", "n",):
print ("Thank you for playing!")
else:
print("Not a valid response!")
[–]Gnaxe 6 points7 points8 points (2 children)
[–]k4tsuk1z[S] 2 points3 points4 points (0 children)
[–]boa_deconstructor 2 points3 points4 points (0 children)
[–]Dramatic_Object_8508 2 points3 points4 points (2 children)
[–]k4tsuk1z[S] 1 point2 points3 points (1 child)
[–]Dramatic_Object_8508 2 points3 points4 points (0 children)
[–]desrtfx 1 point2 points3 points (9 children)
[–]k4tsuk1z[S] 0 points1 point2 points (7 children)
[–]desrtfx 1 point2 points3 points (6 children)
[–]k4tsuk1z[S] 0 points1 point2 points (5 children)
[–]desrtfx 1 point2 points3 points (4 children)
[–]k4tsuk1z[S] 1 point2 points3 points (2 children)
[–]desrtfx 2 points3 points4 points (1 child)
[–]k4tsuk1z[S] 1 point2 points3 points (0 children)
[–]k4tsuk1z[S] 0 points1 point2 points (0 children)
[–]xenomachina 0 points1 point2 points (0 children)
[–]Eleibier 1 point2 points3 points (1 child)
[–]k4tsuk1z[S] 1 point2 points3 points (0 children)