I'm still beginner in python world and one of the things that made my head turns.. is the
List_1 [ :15]
for i in range(15): print i #will print out 0..14 for i in range(1, 15): print i # will print out 1..14 for i in range (a, b, s): print i # will print a..b-1 counting by s. interestingly if while counting by the step 's' you exceed b, it will stop at the last 'reachable' number, example for i in range(1, 10, 3): print i > 1 > 4 > 7
a = "hello" # there are 5 characters, so the characters are accessible on indexes 0..4 a = 'e' a[1:2] = 'e' # because the second number after the colon is not reached. a[x:y] = all characters starting from the character AT index 'x' and ending at the character which is at'y' a[x:] = all characters starting from x and to the end of the string
In the future, if you ever wonder what the behavior of python is like, you can try it out in the python shell. just type python in the terminal and you can enter any lines you want (though this is mostly convenient for one-liners rather than scripts).