@antiqous

Как сделать так чтобы скрипт после своего выполнения не останавливал программу а просто открыл еще одну строку для ввода другой команды?

n1 = input("Say something: ")
if n1 == 'Hello SCUB' or 'start' or 'scub' :
n2 = input("Hello, This is S.C.U.B. - Special Custom Unified Bot v0.1 How can I help you? ")
if n2 == 'calc +':
num_1 = int(input("1st num: "))
num_2 = int(input("2nd num: "))
res = num_1 + num_2
print("Result is:", res)

if n2 == 'calc -':
num_11 = int(input("1st num: "))
num_22 = int(input("2nd num: "))
res = num_11 - num_22
print("Result is:", res)

if n2 == 'calc *':
num_111 = int(input("1st num: "))
num_222 = int(input("2nd num: "))
res = num_111 * num_222
print("Result is:", res)

if n2 == 'calc /':
num_1111 = int(input("1st num: "))
num_2222 = int(input("2nd num: "))
res = num_1111 / num_2222
print("Result is:", res)

if n2 == 'help':
print("List of cmds avaliable on SCUB v0.1:"
" ;help (Help or help or cmds"
" ;Calculator(calc +,-,*,/)")

Например когда запускаю калькулятор то после решения программа полностью останавливается и приходиться её еще раз запускать, надо чтоб после выполнения скрипта меня выбрасывало на переменную n2 (Пробовал while True но команда не выполнялась а просто открывало переменную n2.) Что делать?
  • Вопрос задан
  • 79 просмотров
Решения вопроса 1
@ultraevs
Student
Решение:
n1 = input("Say something: ")
if n1 == 'Hello SCUB' or 'start' or 'scub' :
    n2 = input("Hello, This is S.C.U.B. - Special Custom Unified Bot v0.1 How can I help you? ")
while n2 != '':
    if n2 == 'calc +':
        num_1 = int(input("1st num: "))
        num_2 = int(input("2nd num: "))
        res = num_1 + num_2
        print("Result is:", res)
        n2 = input()
    if n2 == 'calc -':
        num_11 = int(input("1st num: "))
        num_22 = int(input("2nd num: "))
        res = num_11 - num_22
        print("Result is:", res)
        n2 = input()
    if n2 == 'calc *':
        num_111 = int(input("1st num: "))
        num_222 = int(input("2nd num: "))
        res = num_111 * num_222
        print("Result is:", res)
        n2 = input()
    if n2 == 'calc /':
        num_1111 = int(input("1st num: "))
        num_2222 = int(input("2nd num: "))
        res = num_1111 / num_2222
        print("Result is:", res)
        n2 = input()
    if n2 == 'help':
        print("List of cmds avaliable on SCUB v0.1:"
        " ;help (Help or help or cmds"
        " ;Calculator(calc +,-,*,/)")
        n2 = input()
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы