String manipulation
Strings can be manipulated in many ways. The first one we will look at is how to access certain characters.
x = "Ah I see this is a string!" print x[5]
Try the above code. See how only one character is printed? and a “s” no less. If you count the letters you will notice that the 5th letter is a s. This is assuming you start with the first character as 0. Try the code below –
x = "printme"
a = 0
while a< len(x):
print "position",a, "has the character", x[a]
a = a + 1
Try the second code sample. Now change it so it starts at position 3.
Output: (clear)











