I will state the obvious that I am a beginner. I should also mention that I have been coding in Zybooks, which affects things. My textbook hasn't helped me much
I tried sub_lyric= rhyme_lyric[ : ]
Zybooks should be able to input an index number can get only that part of the sentence but my book doesnt explain how to do that. If it throws a [4:7] then it would output cow. Hopefully I have exolained everything well.
You need to set there:
The string is as a sequence of characters and you can use string slicing to extract any sub-text from the main one. As you have observed:
will copy the entire content of
rhyme_lyric
tosub_lyric
.To select only a portion of the text, specify the
start_index
(strings start with index 0) toend_index
(not included).will extract characters in
rhyme_lyric
from position 4 (included) to position 7 (not included) so the result will becow
.You can check more on string slicing here: Python 3 introduction