PI. Strings slicing

Run Settings
LanguagePython
Language Version
Run Command
# A few examples of how strings slicing is working # Let us define some string, one above is pretty famos among font creators s1 = "The quick brown fox jumps over the lazy dog" # Imagine that we will put gaps between all leters here and would number them like: # T h e q u i c k ... # 0 1 2 3 4 5 6 7 8 9 ... # So when you slice, you're actually cut the string from and to gap. # Lets see some examples. # You can easily cut the part of string. print s1[10:20] # Or if you miss first argument it'll be replaced with 0, as default value print s1[:20] # Either if you miss last argument it would be replaced with string length: len(s1) print s1[35:] # Sure, you can miss all of them and just COPY the string print s1[:] # There's a third argument that denotes the step between gaps print s1[::2] # And if you'll make it negative it will revert the string print s1[::-1] # But if one of two first arguments would be negative, think of them as len(s1) - n print s1[-8:]
Editor Settings
Theme
Key bindings
Full width
Lines