Using nested lists and tables
__peter__ at web.de
Thu Oct 28 10:49:48 CEST 2010
> I am trying to make this simple app for GAE.
> I get a string s that user enters in a form.
> I append that to an empty list L =  then I test if the last saved
> string is the same as the new string. If same, I write it on the same
> column; if not the cursor moves to next column (I was trying to do
> this with tables) and as long as the user types the same string the
> cursor stays on the same column. If a new string is typed; a new
> column is started; and so on.
> I asked the same question at Stackoverflow and HN with no good answers
> so far. Maybe you can help. Thanks.
>>> columns = 
>>> def add(s):
... if columns and columns[-1] == s:
>>> while True:
... s = raw_input()
... if not s: break
that's all, folks
[['abc', 'abc', 'abc'], ['xy', 'xy'], ["that's all, folks"]]
>>> for row in range(max(len(c) for c in columns)):
... print " | ".join(c[row] if len(c) > row else " "*len(c) for c in
abc | xy | that's all, folks
abc | xy |
abc | |
More information about the Python-list