Learn String Manipulation by Building a Cipher - Step 23

The issue is described as follows:

The task give in the question was to declare a variable named ‘index’ and assignee
alphabet.find(char) into is bet i tried doing and it was showing error and so i changed it to alphabet.find(“char”) and still it is showing error in the program.

The code:


text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index=alphabet.find("char")
for char in text:
    print(char)

![Screenshot 2023-12-30 163742|690x371](upload://A2sO26qs9T7G5xoN4sXckLEhlUa.png)

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hello ashu,

The question asks you to declare the variable before the print line. With that they emant it has to be inside the for loop, but above the print.
Also char, in this case, is a variable. Just like how printed char as a variable, in the find function you also have to use it as a variable instead of making it into a string.

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