Learn String Manipulation by Building a Cipher - Step 53

Tell us what’s happening:

i dont really understand what they meant by an argument or how to impement it

Your code so far

text = 'Hello Zaira'
shift = 3

def caesar(message, offset):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    encrypted_text = ''

    for char in message.lower():
        if char == ' ':
            encrypted_text += char
        else:
            index = alphabet.find(char)
            new_index = (index + offset) % len(alphabet)
            encrypted_text += alphabet[new_index]
    print('plain text:', message)
    print('encrypted text:', encrypted_text)

# User Editable Region

caesar('message' and 'offset'
)

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 53

An argument is a parameter of the function. When you call the function you pass it some values that it needs to work inside the two brackets.

Just to add to what @hbar1st explained, arguments and parameters are variables, they store values. When you create a function, you can define parameters:

def function(param1, param2):
    return param1 + param2

When you call the function, you pass values to those parameters by using arguments:

function(argument1, argument2)

So the value stored in the variable argument1 will be sent the function and become param1 in the code of the function.

function(1,2)
>>> 3

Here we pass the argument var to the function print():

print(var)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.