Learn String Manipulation by Building a Cipher - Step 28

Tell us what’s happening:

Describe You should add index as the second argument to your existing print(char) call. Don’t forget to separate the arguments with a comma.your issue in detail here.

Your code so far

my code is not passing and getting the following message


# User Editable Region

message = 'Hello World'
index = 0
for char in message:
    print(char, index)
    index += 1You should add index as the second argument to your existing print(char) call. Don't forget to separate the arguments with a comma.






  

# 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 CCleaner/120.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 28

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.

Please talk to us about how the instructions or error message is confusing. Thanks

You should add index as the second argument to your existing print(char) call. Don’t forget to separate the arguments with a comma.

Ok. Instead of copy-pasting the instructions, please talk to us about how the instructions are error message is confusing. Thanks

these are the instructions
Currently, the print() function is taking a single argument char, but it can take multiple arguments, separated by a comma.

Add a second argument to print(char) so that it prints the character and its index inside the alphabet.

these are the instructions

message = ‘Hello World’
index = 0
for char in message:
print(char, index)
index += 1

this was my answer

Sorry, your code does not pass. Keep trying.

You should add index as the second argument to your existing print(char) call. Don’t forget to separate the arguments with a comma.

and this was the reponse

Yes. I know all of that. I am asking you to use your own words to let us know what about all of that you don’t understand and want us to explain more.

ok i have followed the instruction to my best knowledge but it still seems incorrect and i m not sure where the error is it is step 28 of coding with python

What specifically about the instructions do you not understand?

I assume you know what the print function is

I also assume you know what the variable char is?

Do you know what a function argument is?

It’s hard to understand the second part if you don’t know what an argument is

Do you know what they mean by ‘index’? You made a lot of changes from the original code that weren’t ‘add a second argument’.

no i am not sure mean by index

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'

for char in text:
    index = alphabet.find(char)
    print(char)

This is the original code you had. index is the variable inside of the loop on that first line.

Please stop opening duplicate topics for the same step. :+1:

ok can you see where i am going wrong?

You changed the original code defining what index is. The instructions didn’t talk about doing that, so you should undo those changes.

— removed solution code -----

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.