Back to Freecodecamp

Step 6

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

latest837 B
Original Source

--description--

You can also access string characters starting from the end of the string. The last character has an index of -1, the second to last -2 and so on.

Now modify your existing print() call to print the last character in your string.

--hints--

You should still call the print() function.

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

You should pass text[-1] 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*-\s*1\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[6])
--fcc-editable-region--