Возникли проблемы с калькулятором скидок - PullRequest
0 голосов
/ 05 января 2020

Не могу понять, что не так с моим кодом. Он продолжает печатать значение Additional_discount независимо от ввода для student_status. здесь показан код

def discount(x):
    return x * .9

def additional_discount(x):
    return discount(x) * .95

og_price = float(input("Please enter your current price in dolalrs: "))
student_status = str(input("Are you a student? "))

if student_status == "Yes" or "yes"
    print("Your price is ", additional_discount(og_price))
elif student_status == "No" or "no":
    print("Your price is ", discount(og_price))
else:
    print("I'm sorry, that is an invalid response")

Спасибо!

1 Ответ

0 голосов
/ 05 января 2020

Вам следует изменить условие if:

if student_status in ['Yes', 'yes']:
  do something
elif student_status in ['No', 'no']:
  do

Используемое вами утверждение: if student_status == 'Yes' or 'yes'. Это означает student_status == 'Yes' или 'yes'. Логическое значение для 'yes' равно True, поэтому условие всегда выполняется.

Вы можете обратиться к здесь для логического значения python объектов.

...