S
S
Soldat22832020-05-22 18:48:36
Python
Soldat2283, 2020-05-22 18:48:36

Why is only part of the code executed?

I wrote a code for converting currencies when you choose the dollar, everything is fine, but as soon as you choose something else, it counts at the dollar rate. Why?
Immediately I say I'm a beginner)
Here is the code

print("Вас приветствует конвертер валют!")
operation = str(input("Выберите валюту(USD,EUR,RUB,MDL,UAH)"))
valute = float(input("Введи количество:"))
# Доллар
if operation == "USD" or 1:
    money_rub = valute * 16.3
    print("Ваша валюта в рублях ПМР:" + str(money_rub))
# Евро
elif operation == "EUR" or 2:
    money_rub = valute * 17.65
    print("Ваша валюта в рублях ПМР:" + str(money_rub))
# Рубли россии
elif operation == "RUB" or 3:
    money_rub = valute * 0.2245
    print("Ваша валюта в рублях ПМР:" + str(money_rub))
# Леи
elif operation == "MDL" or 4:
    money_rub = valute * 0.8700
    print("Ваша валюта в рублях ПМР:" + str(money_rub))

elif operation == "UAH" or 5:
    money_rub = valute * 0.57
    print("Ваша валюта в рублях ПМР:" + str(money_rub))
else:
    print("Выбранна неверная валюта")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2020-05-22
@Soldat2283

if operation == "USD" or 1:
This condition is always true, == takes precedence over or

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question