Learn String Manipulation by Building a Cipher - Step 4

Tell us what’s happening:

Describe your issue in detail here.

I don’t get it

Your code so far


/* User Editable Region */

text = 'Hello World'
print(o)

/* User Editable Region */

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 4

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.

To access a char in a string the correct syntax is stringvariable[index]. inside print() function apply as per correct syntax.

So the instruction of this challenge is:
instead of printing text , print just the character at index 6 .

So printing text would print out ‘Hello World’ because that’s what’s contained in the variable.

But in this case, the challenge is asking only for the letter on text variable that is in the 6th index position. This is the string sequence contained within the text variable:
H = 0
e = 1
l = 2
l = 3
0 = 4
empty = 5
W = 6
o = 7
r = 8
l = 9
d = 10

But again, the challenge is how to only print out the letter in the 6th index position?
The concept of brackets [ ] come into play, as brackets give access to a sequence within a variable. Think of it like a door that opens into what’s contained within the variable.

So, the variable to access is text.
And to access the string sequence within that variable, you place a bracket [ ] next to text.
Then place the number of the index position asked for within the bracket.

Finally, pass this into the print function.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.