Computers/Language python

string vs. list

emzei 2012. 3. 14. 16:30

Structured Data


 String

List 

 Sequence of characters

sequence of anything 

 s = ' yabba! '

p = [ 'y', 'a', 'b' , 'b' , 'a' , '!' ]

s[0] = 'y'

s[0] = 'y' 

s[2:4] = 'bb' 

s[2:4] = [ 'b', 'b' ] 



<list> -> [ <expression>, <expression>, ... ]


'Computers > Language python' 카테고리의 다른 글

Mutation / Aliasing  (0) 2012.03.14
Nested Lists  (0) 2012.03.14
web crawler : url 링크가 더이상 존재하지 않을 때  (0) 2012.03.14
multiple assignment  (0) 2012.03.14
Loops / loop  (0) 2012.03.14