String Indexing

Python / Basics

string = 'proton'
string[:]               # proton
string[:2]              # pr
string[-2:]             # on
string[1:3]             # ro

# reverse a string
string[::-1]            # notorp

# skip every second character
string[0:-1:2]          # poo

'''
Michael Sjoeberg
2018-11-05
https://github.com/michaelsjoeberg/python-playground/blob/master/basic-syntax/string-indexing.py
'''