Step 12 scientific computing beta

need answers

a_string.find(char)

alphabet = 'abcdefghijklmnopqrstuvwxyz'

print()find(alphabet[0])

what answers do you need?

can you provide a link to the step?

The first kind of cipher you are going to build is called a Caesar cipher. Specifically, you will take each letter in your message, find its position in the alphabet, take the letter located after 3 positions, and replace the original letter with the new letter.

Start by finding the position of the first letter in the string. One way is to use the built-in find() function:

a_string.find(char)

Above, char is the character you want to locate, and a_string is the string you want to parse.

At the end of your code, call find() on your alphabet string and pass text[0] to the function.

I have no idea what it means when it says Above, char is the character you want to locate, and a_string is the string you want to parse.

If I wanted to find the letter “q” in this string:

string_variable = "This is quite a pickle."

I would code this:

string_variable.find("q")

or

char = "q"
string_variable = "This is quite a pickle."
position = string_variable.find("q")
print(position)

And position would store the position of the letter “q” in that sentence, which is the number 8.

a_string.find(char)

This is giving you the generic syntax for how to use the find() function.
String, Find, Character.
string.find(character)
It will result in the position number of that letter in a string, which you can print or store in a variable.

OK thanks man. I will try it next time I am on

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