Python Strings Challenge II

When doing the string challenges, I came across a way to slice that is useful to the exercises.


string = "hello world"
print(string[0:5])  # prints "hello"
print(string[6:])  # prints "world"
print(string[::-1])  # prints "dlrow olleh"
print(string[::2])  # prints "hlowrd"

We were taught the first 2, but the last two are the most important.
The third is a way to reverse the string by using a step size of -1.
The fourth is a way to do every other string with a step size of 2.

The start/stop defaults to all strings, so leaving them empty means going through the entire string.