FAQ: String Methods - Splitting Strings III

This community-built FAQ covers the “Splitting Strings III” exercise from the lesson “String Methods”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

FAQs on the exercise Splitting Strings III

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

In this splitting string exercise, what is the given syntax in the string “= /”.

spring_storm_text =
“”"The sky has given over
its bitterness.

To my knowledge, we have not been exposed to this syntax. Is this an unmentioned escape sequence? I don’t see an end to the /" and based on the notes from the discussion forum it looks like there should be one if indeed that’s what this syntax is.

It is a backslash, not a forward slash:

spring_storm_text = \
"""The sky has given over 
its bitterness. 
Out of the dark change 
...
"""

… and it is read by the Python interpreter as a line split marker. Without it, the single, isolated line, spring_storm_text = would throw a syntax error.

In Python, there are two ways that you can split a line. One is by use of the backslash, as seen here, and the other is by means of parentheses, brackets or curly braces, within which any line can be split.

Why do they want to split this particular line? Probably so that the poem would look nice on-screen. Without the split, it would be:

spring_storm_text = """The sky has given over 
its bitterness. 
Out of the dark change 
...
"""

… not as pretty, you might agree.

It is unfortunate that this was used in a lesson dealing with escape sequences, for it is not an escape sequence marker. Escape sequences occur only within a string.

got it! Thanks

they throw some random stuff out every once and awhile.

1 Like