как передать 2 аргумент в функцию?

Рейтинг: -1Ответов: 1Опубликовано: 01.04.2023
alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


def encrypt(key, message):
    result = ""

    for i in message:
        if i not in alp:
            continue
        elif i in alp:
            letter = (alp.find(i) + key) % len(alp)
            result += alp[letter]
    print(result)
    return key, result


def decryption(key, result):
    message = ""

    for i in result:
        letter = (alp.find(i) - key) % len(alp)
        message += alp[letter]
    print(message)


while True:
    'encrypt(int(input("Сдвиг: ")),str(input("Сообщение: ")).upper())'
    decryption(encrypt(int(input("Сдвиг: ")), str(input("Сообщение: ")).upper()))

Вот весь мой полный код, пайчарм указывает на строчку decryption(encrypt(int(input("Сдвиг: ")), str(input("Сообщение: ")).upper())) и выводит TypeError: decryption() missing 1 required positional argument: 'result'

(Этот код - интерпретация шифра цезаря) Мне нужна помощь, как передать аргументы key и result в функцию decryption

Ответы

▲ 0

Решил сам эту проблему в итоге вышло:

alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


def encrypt(key, message):
    result = ""

    for i in message:
        if i not in alp:
            continue
        elif i in alp:
            letter = (alp.find(i) + key) % len(alp)
            result += alp[letter]
    print(f"Полученный шифр: {result} -> {result.lower()}")
    return key, result


def decryption(key, result):
    message = ""

    for i in result:
        letter = (alp.find(i) - key) % len(alp)
        message += alp[letter]
    print(f"Полученная расшифровка: {message} -> {message.lower()}")


while True:
    try:
        a, b = encrypt(int(input("\nСдвиг: ")), str(input("Сообщение: ")).upper())
        decryption(a, b)
    except:
        continue