Back to Freecodecamp

Step 27

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/655220953ba90d80514d7ee2.md

latest907 B
Original Source

--description--

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.

--hints--

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

js
({test: () => {
    const commentless_code = __helpers.python.removeComments(code);
    const {block_body} = __helpers.python.getBlock(commentless_code, /for\s+char\s+in\s+text\s*/);
    assert(block_body.match(/print\s*\(\s*char\s*,\s*index\s*\)\s*$/));
  }
})

--seed--

--seed-contents--

py
--fcc-editable-region--
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'

for char in text:
    index = alphabet.find(char)
    print(char)
--fcc-editable-region--