Learn String Manipulation by Building a Cipher - Step 47

Tell us what’s happening:

I am unable to figure this out because the topics related to my problem only give the instruction
my problem isn’t following the instruction i understand it actually but i dont know what calling a function really is

i get thath i have to write at the bottom of the already existing code but what do I write?

Your code so far


# User Editable Region

text = 'Hello Zaira'
shift = 3

def caesar():
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    encrypted_text = ''

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


# 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/120.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 47

image

in the instruction syntax for function call is given. also u have been instructed to call function caesar . follow the syntax. replace function_name with caesar and put (). u should call u function outside function definition.

this set is function definition. u have to call function after this. call function

u see here def starts. like wise call the function at end where def started.

3 Likes

I’ve failed with respect that i tried following your guidance but i failed thank you for the assist

1 Like

actually it is simple to implement. can u share currently what u have done in the code

1 Like

I’ve reset it because it wasn’t working
so i kinda just left it alone for now

1 Like

text = ‘Hello Zaira’
shift = 3

def caesar():
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
encrypted_text = ‘’

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

this is where I am stuck I can’t change the name ;
def function_name(caeser())

2 Likes

reset the code. after that below function call the function caesar() and share the code. in this way i can help u where u have done wrong

2 Likes

ayt OG i’ll follow your orders

1 Like

text = ‘Hello Zaira’
shift = 3

def caesar():
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
encrypted_text = ‘’

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

caeser()

1 Like

can u share screenshot of ur work. i see some indentations missing. i just want to confirm is the error is because of indentations

1 Like

aaronvincent6411 is right just be careful with indentations. So no indentation when calling function at the end. Everything inside the def caesar(): should have one indentation plus the indentation they would normally would’ve. I don’t think anything is wrong with your code except for indentations. Just make sure when you are calling your caesar function, don’t use any indentation.

I hope you get it right! Because not gonna lie, I was stuck on this question too! :slight_smile:

i would have to apologize to you guys the reason why it wasn’t working was because when i tried to call function_name as caesar i spelt it " CAESER " instead of the actual word “CAESAR”
the A at the end actually was the problem

2 Likes

Great! Sometimes you really can’t notice different when so much thing is going on your mind, so it is good to just leave it and come back with a fresh mind! Glad you solve the problem :slight_smile:

2 Likes

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