# The value of a string cannot be changed once it is set; # it is immutable >>> s = "abc" >>> s.upper() Out[41]: 'ABC' >>> s Out[42]: 'abc' >>> s[0] Out[43]: 'a' >>> s[0] = 'h' Traceback (most recent call last): File "/Users/rcd/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2721, in run_code exec code_obj in self.user_global_ns, self.user_ns File "", line 1, in s[0] = 'h' TypeError: 'str' object does not support item assignment # You can reassign its value, but not change it directly >>> s = s.upper() >>> s Out[49]: 'ABC' >>> s += 'def' >>> s Out[51]: 'ABCdef' >>> s = s + 'def' # Lists are different, they can be changed directly (assigned to # or using their methods); thus lists are mutable >>> l = [ 5, 10, 15, 20 ] >>> l[0] = 33 >>> l Out[47]: [33, 10, 15, 20] >>> l.remove(33) >>> l Out[54]: [10, 15, 20] # String methods return a new string, but list methods return None >>> type(s.upper()) Out[55]: str >>> type(l.remove(10)) Out[56]: NoneType # Also, some functions can take a variety of parameters, like range: >>> range(3) Out[57]: [0, 1, 2] >>> range(11, 13) Out[58]: [11, 12] >>> range(100, 200, 10) Out[59]: [100, 110, 120, 130, 140, 150, 160, 170, 180, 190]