Back to Freecodecamp

Step 5

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/6551f3bfed58796ebb1268dc.md

latest1.1 KB
Original Source

--description--

Each string character can be referenced by a numerical index. The index count starts at zero. So the first character of a string has an index of 0. For example, in the string 'Hello World', 'H' is at index 0, 'e' is at index 1, and so on.

Each character of a string can be accessed by using bracket notation. You need to write the variable name followed by square brackets and add the index of the character between the brackets:

py
text = 'Hello World'
r = text[8]

Now, instead of printing text, print just the character at index 6.

--hints--

You should still call the print() function.

js
assert.match(code, /print\s*\(.*\)/)

You should pass text[6] to the print() function by including it between the parentheses. Pay attention to place the function call at the beginning of the line.

js
assert.match(code, /^print\s*\(\s*text\s*\[\s*6\s*\]\s*\)/m)

Your code contains invalid syntax and/or invalid indentation.

js
({test: () => assert(true) })

--seed--

--seed-contents--

py
--fcc-editable-region--
text = 'Hello World'
print(text)
--fcc-editable-region--