Thanks Japhy Bartlett!
[[0] for i in range(5)]
Works! I converted to fit into my routine as:
lens = [[] for i in range(len(catalog2[0]))] the new statement
for row in catalog2:
for col, item in enumerate(row):
lens[col].append(len(item))
lens = [max(col) for col in lens]
Alan Gauld
Hi!
We are not quite out of the woods on this last example you gave me. It
now seems to be complaining
that it doesn't want to append an integer to the list or that this isn't
the place to use '.append' -- I am probably interpreting it's complaint
wrong:
Python 3.3
If I run
On Aug 20, 2014 12:07 PM, Terry--gmail terry.kemme...@gmail.com wrote:
Alan Gauld
Hi!
We are not quite out of the woods on this last example you gave me. It
now seems to be complaining
that it doesn't want to append an integer to the list or that this isn't
the place to use '.append' -- I
Marc, my understanding is, is that:
lens[col].append(len(item))
-should be building a mirror image of my list of lists called catalog2,
which currently has 9 columns by x number of rows, and that we are
plugging into these positions, the sizes of all the elements in that
block of data.
On Wed, Aug 20, 2014 at 1:38 PM, Terry--gmail terry.kemme...@gmail.com wrote:
Marc, my understanding is, is that:
lens[col].append(len(item))
-should be building a mirror image of my list of lists called catalog2,
which currently has 9 columns by x number of rows, and that we are
Terry--gmail wrote:
Marc, my understanding is, is that:
lens[col].append(len(item))
-should be building a mirror image of my list of lists called catalog2,
which currently has 9 columns by x number of rows, and that we are
plugging into these positions, the sizes of all the elements
Hi Marc Tompkins!
You are absolutely right that
lens = [0] * len(catalog2[0])
Just creates a list of integers!
Here is what happened, my original method of finding the maximum element
sizes in the 9 x ? block of data held in catalog2, only needed a final
list of integers to contain it.
lens = [0] * len(catalog2[0])
Ah. Read the following closely:
https://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list
If you have any questions, please feel free to ask further. See if
that clears up the mistake that's in your code.
On 20/08/14 20:06, Terry--gmail wrote:
We are not quite out of the woods on this last example
lens = [0] * len(catalog2[0])
This is what happens when you don't test code.
My apologies, the initialisation is all wrong.
Try this instead:
lens = [ [] for n in catalog2[0] ]
That adds an
this forms a list of integers
[0]*5
[0, 0, 0, 0, 0]
what I think you want is something like:
[[0] for i in range(5)]
[[0], [0], [0], [0], [0]]
(a list of lists)
foo = [[0] for i in range(5)]
foo[3].append('bar')
foo
[[0], [0], [0], [0, 'bar'], [0]]
On Wed, Aug 20, 2014 at 3:56 PM,
On Mon, Aug 18, 2014 at 1:00 AM, Marc Tompkins marc.tompk...@gmail.com wrote:
Also, looking at the Ninja-IDE website more closely I see that,
although they do mention compatibility with multiple languages, they
were designed by and for Python programmers - which makes the
tab/space issue less
On 19/08/2014 19:14, Marc Tompkins wrote:
On Mon, Aug 18, 2014 at 1:00 AM, Marc Tompkins marc.tompk...@gmail.com wrote:
Also, looking at the Ninja-IDE website more closely I see that,
although they do mention compatibility with multiple languages, they
were designed by and for Python
On Tue, Aug 19, 2014 at 1:04 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
I'm not aware of any problem with Thunderbird or any (semi-)decent mail
client.
The original poster uses NinjaIDE and Thunderbird, and his code was
being persistently flattened when he copied/pasted. I believe I've
On 19Aug2014 13:29, Marc Tompkins marc.tompk...@gmail.com wrote:
On Tue, Aug 19, 2014 at 1:04 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
I'm not aware of any problem with Thunderbird or any (semi-)decent mail
client.
It may depend a great deal on the source program.
The original
The down side of setting the python.org domain to be mailed to as plain
text, appears to be that Thunderbirdy has changed all my email to plain
text, instead of just the email going to this domainwhich is weird.
Leam Hall:
I have just one additional function to create in the User Design
On 19Aug2014 16:41, Terry--gmail terry.kemme...@gmail.com wrote:
The bare 'except' was a throw away. By bare 'except' I am assuming you mean
without defining the type of error 'except' is to act upon?
try:
something
except ValueError:
do something
-Or does bare 'except' mean something
On 19Aug2014 16:41, Terry--gmail terry.kemme...@gmail.com wrote:
Alan Guald:
I have been trying out the different ways you suggested for doing
this, and have ran into a problem on making the very last one work. I
stuck a print statement in it to help, but I am not sure what the
error
On 19Aug2014 16:41, Terry--gmail terry.kemme...@gmail.com wrote:
Alan Guald:
[...]
lens = [max(col) for col in lens]
[...]
Also, the list comprehension you have used on the final line reminds
me that I would really like to understand comprehensions better. Is
there some info on the Internet
On 19/08/14 23:41, Terry--gmail wrote:
Alan Guald:
for row in catalog2:
print(row)
for col, item in row:
lens[col].append(len(item))
My bad, it should have been
for col, item in enumerate(row):
Sorry,
--
Alan G
Author of the Learn to Program web site
On Sun, Aug 17, 2014 at 10:51 PM, Terry--gmail terry.kemme...@gmail.com wrote:
I'm copy and pasting from Ninja-IDE, which I thought was created
specifically to do python programming...
Specifically for programming, yes, and Python is among the supported
languages - but according to their web
On 17Aug2014 23:51, Terry--gmail terry.kemme...@gmail.com wrote:
I'm copy and pasting from Ninja-IDE, which I thought was created
specifically to do python programming...so I never checked to see if
it needs to have the tab set to enter 4 spaces, as it appeared
visually to be doing that. But,
On Mon, Aug 18, 2014 at 12:13 AM, Cameron Simpson c...@zip.com.au wrote:
On 17Aug2014 23:51, Terry--gmail terry.kemme...@gmail.com wrote:
I'm copy and pasting from Ninja-IDE, which I thought was created
specifically to do python programming...so I never checked to see if it
needs to have the
WOW! There is a lot of help on this mailing list! I want to thank
everyone for their valuable input! Thanks! (I am working my way through
the replies.)
Sorry about the HTML. I think I have it turned off now in Thunderbirdy
for this address. If so, then what follows should not be flat. If it
On 18/08/14 00:48, Terry--gmail wrote:
Sorry about the HTML. I think I have it turned off now in Thunderbirdy
for this address. If so, then what follows should not be flat. If it is
flat, please tell me.
Still flat for me... Sorry.
The fact is, I am VERY interested in acquiring that
On Sun, Aug 17, 2014 at 4:48 PM, Terry--gmail terry.kemme...@gmail.com wrote:
WOW! There is a lot of help on this mailing list! I want to thank everyone
for their valuable input! Thanks! (I am working my way through the
replies.)
Sorry about the HTML. I think I have it turned off now in
I found another place in Thunderbirdy to set 'plain text'.
This is a test.
Does the below code look correct now?
--And did I reply correctly this time? (Reply-All and keep only
tutor@python.org address...)
for line_number, row in enumerate(catalog2):
for col, item in enumerate(row):
if
On Sun, Aug 17, 2014 at 9:40 PM, Terry--gmail terry.kemme...@gmail.com wrote:
I found another place in Thunderbirdy to set 'plain text'.
This is a test.
Does the below code look correct now?
--And did I reply correctly this time? (Reply-All and keep only
tutor@python.org address...)
On Sun, Aug 17, 2014 at 9:49 PM, Marc Tompkins marc.tompk...@gmail.com wrote:
On Sun, Aug 17, 2014 at 9:40 PM, Terry--gmail terry.kemme...@gmail.com
wrote:
I found another place in Thunderbirdy to set 'plain text'.
This is a test.
Does the below code look correct now?
--And did I reply
On 17Aug2014 22:40, Terry--gmail terry.kemme...@gmail.com wrote:
I found another place in Thunderbirdy to set 'plain text'.
This is a test.
You message is plain text now. Thank you!
Does the below code look correct now?
--And did I reply correctly this time? (Reply-All and keep only
I'm copy and pasting from Ninja-IDE, which I thought was created
specifically to do python programming...so I never checked to see if it
needs to have the tab set to enter 4 spaces, as it appeared visually to
be doing that. But, I don't remember whether I used their tab or
manually typed 4
Python 3.3
This has something to do with the nature of FOR statements and IF
statements, and I am sure it must be a simple mistake...but I seem to be
stumped.
I am writing a starship encounter program as my first real python
programwhere the user gets a random amount of credits to
Thanks for your response JL.
I added the following Exception to the code snippet:
for line_number in range(len(catalog2)):
for col in range(len(catalog2[line_number])):
try:
if lens[col] len(catalog2[line_number][col]):
lens[col] = len(catalog2[line_number][col])
except TypeError:
On Fri, Aug 15, 2014 at 10:46 AM, Terry--gmail terry.kemme...@gmail.com wrote:
(By the way - your indentation got flattened - cue the inevitable
chorus of DON'T POST TO THIS LIST IN HTML - so this is my best-guess
reconstruction.)
lens = []
# pre-format the list called lens for maximum number
On a totally side note, I'm watching this because I want to do my own
starship stuff. Long time Traveller player.
--
Mind on a Mission
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
Terry--gmail terry.kemme...@gmail.com Wrote in message:
Please don't post here in html mail. Tell your email program to
use text. Your program fragment displayed here as a mess, which
is one of many problems with html.
Please use reply-list (or whatever your email supports, like
reply-all
Hi,
My thoughts are in the message:
- Original Message -
From: Terry--gmail terry.kemme...@gmail.com
To: Python_Tutor -- Mailing List tutor@python.org
Date sent: Fri, 15 Aug 2014 11:46:49 -0600
Subject: [Tutor] Building Starships -- object of type 'int' has
no len()
Python 3.3
terry.kemme...@gmail.com
To: Python_Tutor -- Mailing List tutor@python.org
Date sent: Fri, 15 Aug 2014 13:21:17 -0600
Subject: [Tutor] Building Starships -- object of type 'int' has
no len()
Thanks for your response JL.
I added the following Exception to the code snippet:
for line_number in range
37 matches
Mail list logo