May 17, 2013

Python Strings

Python Strings:

1)
Stings can be enclosed by " ( double quotes ) or  ' ( single quotes )
escaping works on both single quotes and double quotes

2)
Also, we can have multi-line strings.
- But for multiline strings, it has to be escaped by \
- Or we can use """ or '''

example:

a = " this is \
multinline string "

a = """ this is
multine string """


3)
String in python are immutable. i.e. once assigned, it can't be changed.
i.e. all manipulative operations are resulted into new string

4)
we can use [] operator to access string characters
starting from 0 index

s = 'hello'
s[1] will be 'e'

len function returns lenght of the string


4).
There is no ++ operator in python