On 22/02/12 13:14, David Craig wrote:
Hi,
I have created a list of containing strings that represent distances
between many different points and would like to display the results in a
table.
Others have mentioned using format strings.
If it is only for display you could switch to html.
Then de
On Wed, Feb 22, 2012 at 10:24 AM, David Craig wrote:
> you had me worried for a minute, but
> a = [[]] * 3
> a[0]=[1,2,3]
> a
> [[1, 2, 3], [], []]
>
That's not the same thing. In your example you create three copies of the
same empty list inside your outer list. You then throw away the first
Thanks everyone, was able to get what I wanted from '/t' but I'm sure
the other formatting options will be useful in future.
@Peter
a = [[]] * 3
>>> a
[[], [], []]
>>> a[0].append(42)
>>> a
[[42], [42], [42]]
you had me worried for a minute, but
a = [[]] * 3
a[0]=[1,2,3]
a
[[1, 2, 3], [
David Craig wrote:
> distance = [[]]*len(stations)
That doesn't do what you think it does:
>>> a = [[]] * 3
>>> a
[[], [], []]
>>> a[0].append(42)
>>> a
[[42], [42], [42]]
See? You get a list that contains the same list len(stations) times. Use
[[] for _ in stations]
instead.
__
David Craig wrote:
I have been trying to write them to a text file but it is difficult to
organise them into rows and columns with appropriate spacing to make it
readable. I would like something like,
Stations Station1 Station2
Station1 0.033.57654
Station2 33
On 22/02/2012 13:40, Evert Rol wrote:
Hi,
This is always a tricky thing to go about. Nicely human-readable doesn't imply
nicely machine readable. Sometimes a single space or a single tab between
values/columns is more practical for a(nother) program to read, but not for
humans.
So I will work
> Hi,
> I have created a list of containing strings that represent distances between
> many different points and would like to display the results in a table.
> I have been trying to write them to a text file but it is difficult to
> organise them into rows and columns with appropriate spacing to