Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-21 Thread Terry--gmail
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]

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Terry--gmail
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Marc Tompkins
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Terry--gmail
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.

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Marc Tompkins
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Peter Otten
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Terry--gmail
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.

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Danny Yoo
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.

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Alan Gauld
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-20 Thread Japhy Bartlett
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,

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-19 Thread Marc Tompkins
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-19 Thread Mark Lawrence
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-19 Thread Marc Tompkins
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-19 Thread Cameron Simpson
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-19 Thread Terry--gmail
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-19 Thread Cameron Simpson
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-19 Thread Cameron Simpson
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-19 Thread Cameron Simpson
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-19 Thread Alan Gauld
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-18 Thread Marc Tompkins
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-18 Thread Cameron Simpson
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,

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-18 Thread Marc Tompkins
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

[Tutor] Building Starships -- object of type 'int' has no len()

2014-08-17 Thread Terry--gmail
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-17 Thread Alan Gauld
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-17 Thread Marc Tompkins
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-17 Thread Terry--gmail
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-17 Thread Marc Tompkins
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...)

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-17 Thread Marc Tompkins
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-17 Thread Cameron Simpson
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-17 Thread Terry--gmail
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

[Tutor] Building Starships -- object of type 'int' has no len()

2014-08-15 Thread Terry--gmail
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

[Tutor] Building Starships -- object of type 'int' has no len()

2014-08-15 Thread Terry--gmail
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:

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-15 Thread Marc Tompkins
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-15 Thread leam hall
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:

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-15 Thread Dave Angel
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-15 Thread Joseph Lee
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

Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-15 Thread Joseph Lee
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