Skip to content

Instantly share code, notes, and snippets.

@podopie
Created September 4, 2013 22:24
Show Gist options
  • Save podopie/6443639 to your computer and use it in GitHub Desktop.
Save podopie/6443639 to your computer and use it in GitHub Desktop.
Python 2.7.5 |Anaconda 1.6.1 (x86_64)| (default, Jun 28 2013, 22:20:13)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 'abc'[1]
'b'
>>> 'abc'[1] = 'c'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment
>>> array = ['dog', 'cat', 'duck']
>>> array[0]
'dog'
>>> array[0] = 'pug'
>>> array[0]
'pug'
>>> tups = ('dog', 'cat', 'duck')
>>> tups[0]
'dog'
>>> tups[0] = 'pug'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> someString = 'this is a string! You cant change me!'
>>> someString[1]
'h'
>>> someString[1] = 'd'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment