Reputation: 13
it keeps repeating please help me
new_custom = ""
while new_custom !=["y","n"]:
new_custom = input("are you a new customer y/n \n").lower
if new_custom == "y":
if miles <= 5:
print (7)
else:
print( 7 + ((miles - 5) * 2))
elif new_custom == "n":
if miles <= 5:
print(8)
else:
print(8+((miles-5)*2))
i cant figure out why it keeps repeating
Upvotes: 0
Views: 40
Reputation: 321
There are 2 errors present in your code:
new_custom !=["y","n"]
This does not check if a string is contained in the list; it checks to see if a list containing the same elements is present.
input("are you a new customer y/n \n").lower
By missing the brackets your script does not realise that lower is a function.
Using these 2 lines will correct your code:
while new_custom not in ["y","n"]:
new_custom = input("are you a new customer y/n \n").lower()
Upvotes: 1
Reputation: 22
You missed the parentheses on your lower case check. Should be .lower() and the code should continue but the next error will be miles is not defined.
Upvotes: 0
Reputation: 350
your while condition should be like this:
miles = 8
new_custom = ""
while new_custom not in ["y","n"]:
new_custom = input("are you a new customer y/n \n").lower()
if new_custom == "y":
if miles <= 5:
print (7)
else:
print( 7 + ((miles - 5) * 2))
elif new_custom == "n":
if miles <= 5:
print(8)
else:
print(8+((miles-5)*2))
Upvotes: 0