# Need some help with my code

``````n1 = int(input("What is your first number?"))
n2 = int(input("What is your second number?"))
func = input("What is the function you want to carry out?")

return n1 + n2

def subtract(n1, n2):
return n1 - n2

def multiply(n1, n2):
return n1 * n2

def division(n1, n2):
return n1/n2

replay = True

while replay:
elif func == "subtract":
print(subtract(n1, n2))
elif func == "multiply":
print(multiply(n1,n2))
elif func == "divide":
print(division (n1,n2))
else:
print("Function not known")

retry = input("Do you want to carry out another function?Y or N")
if retry =="Y" or "y":
replay = True
elif retry == "N" or "n":
replay = False
``````

my question here is in the above code if i indent the last five lines once that is

``````retry = input("Do you want to carry out another function?Y or N")
if retry =="Y" or "y":
replay = True
elif retry == "N" or "n":
replay = False
``````

then it is returning the answer from the first time i ran the code
why?

i know the code is wrong in some places, i am trying to fix the bugs

You only ever ask for input once, at the beginning of the program, don’t you?

That code first calculate retry = ‘Y’ the it calculates ‘y’ that is always true.

You need something like:

``````If retry == ‘Y’ or retry == ‘y’:
``````

aaah okkk i get now

well what if the user wants to calculate something again

i am just trying it make things a little bit harder and better to understand it better
i know there are other ways to do this thing

You know how to repeat things: with a loop.

Python has a number of ways to do what you where doing to match Y and y.

For example you could use the `in` operator like this:

``````if retry in ('Y', 'y'):
``````

Also you could lower case the string so that you do not need to check Y and y like this:

``````if retry.lower() == 'y':
``````

The `lower()` has an addvantage if you are matching words.

``````if retry.lower() == 'yes':
``````

As it will work with `Yes’, ‘YeS’, etc.

thank you, i did know the last two features