Back to Freecodecamp

Step 7

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

latest1.1 KB
Original Source

--description--

You can access the number of characters in a string with the built-in len() function.

Modify your existing print() call by passing len(text) instead of text[-1].

--hints--

You should call the len() function.

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

You should pass the variable text to the len() function by including it between the parentheses.

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

You should pass len(text) 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*len\s*\(\s*text\s*\)\s*\)/m)

You should not have print(text[-1]) in your code.

js
const commentless_code = __helpers.python.removeComments(code)
assert.notMatch(commentless_code, /print\s*\(\s*text\s*\[\s*-\s*1\s*\]\s*\)/)

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[-1])
--fcc-editable-region--