Sub-strings and variables
When you use the sub-string feature the result can be stored in a variable. The code example below demonstrates this.
text = "hello world" hi = text[0:5] world = text[6:11] text = "goodbye world" print hi, "silly", world print text
Once the sub-string is stored in a variable you can change the original without effecting the extracted strings. That is why the output still says “hello silly world” even though the original text has changed. Alter the code below so the text “joe” is extracted from the string text.
text = "extract joe from here!" joe = text[?????] print joe, "is now safe!"
Output: (clear)











