Help with code please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help with code please

what = input( "Выберите действие (+,-,*,/): ") if what == "+" or "-" or "*" or "/": a = float(input("Введите первое число: ")) b = float(input("Введите второе число: ")) else: print( "Выбрана неверная операция! Пока что работает только умножение (*), деление (/), сложение - (+) и вычитание (-)") if what == "+": c = a + b print( "Если сложить " + str(a) + " и " + str(b) + " получится " + str(c )) elif what == "-": c = a - b print( "Если вычесть " + str(b) + " из " + str(a) + " получится " + str(c)) elif what == "*": c = a * b print( "Если умножить " + str(a) + " на " + str(b) + " то получится " + str(c)) elif a == 0: print("На ноль делить нельзя!") elif b == 0: print("На ноль делить нельзя!") elif what == "/": c = a / b print( "Если разделить " + str(a) + " на " + str(b) + " то получится " + str(c)) input()

9th Nov 2019, 1:13 PM
pasem
pasem - avatar
3 Answers
+ 4
I don't think this code will ever work on Sololearn, even if you make it right. (because of the inputs) The mistake I see is in line 3: it should be: if what == "+" or what =="-" or what =="*" or what=="/": I am not sure about this one, but it may work too. if what in ["+", "-", "*", "/"]:
9th Nov 2019, 1:26 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
0
thanks
9th Nov 2019, 2:12 PM
pasem
pasem - avatar
0
and i have one more problem,how i can stop the code after if what==
9th Nov 2019, 2:13 PM
pasem
pasem - avatar