code indentation
Ben Finney
bignose+hates-spam at benfinney.id.au
Thu Jul 26 20:31:30 EDT 2007
vedrandekovic at v-programs.com writes:
> here is my failed example of try with string:
>
> kl="n=90;if n==90:print'kajmakimar'"
>
> for line in kl.split(";"):
> li=[]
> m=li.append(line)
> if line.endswith(':'):
> m.append("\n\t\t\t\t\t\t\t\t")
> print m
The list.append method returns None. It appends the item to the list.
>>> lines = []
>>> result = lines.append("foo")
>>> print result
None
So, there's no need to do anything with the result of append() -- just
continue using the list object.
>>> print lines
['foo']
>>> lines.append("bar")
>>> print lines
['foo', 'bar']
--
\ "There are only two ways to live your life. One is as though |
`\ nothing is a miracle. The other is as if everything is." -- |
_o__) Albert Einstein |
Ben Finney
More information about the Python-list
mailing list