[Tutor] New to programming question

2005-04-12 Thread Ben Markwell
This is an exercise from "How to think like a Computer Scientist." The following example shows how to use concatenation and a for loop to generate an abecedarian series. "Abecedarian" refers to a series or list in which the elements appear in alphabetical order. For example, in Robert McCloskey

Re: [Tutor] New to programming question

2005-04-12 Thread Brian van den Broek
Ben Markwell said unto the world upon 2005-04-12 12:56: This is an exercise from "How to think like a Computer Scientist." The following example shows how to use concatenation and a for loop to generate an abecedarian series. "Abecedarian" refers to a series or list in which the elements appear i

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-13 Thread Joseph Quigley
>Well you did come up with a way that would work sort of and you seem to be >ont eh right track. I would make 1 small change if using your approach. > >prefixes = 'JKLMNOPQ' >suffix = 'ack' > >for letter in prefixes: > if letter == 'O' or letter == 'Q': print letter + 'u' + suffix > else: print l

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-13 Thread jfouhy
Quoting Joseph Quigley <[EMAIL PROTECTED]>: > prefixes = 'JKLMNOPQ' > suffix = 'ack' > > for letter in prefixes: > if letter == ('O') or ('Q'): > print letter + 'u' + suffix > else: > print letter + suffix Hi Joseph, This still won't work. The reason is that your if statement is

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-13 Thread Ben Markwell
Thanks for everybodys input. Am learning slowly but surely. Ben On 4/13/05, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:Quoting Joseph Quigley <[EMAIL PROTECTED] >:> prefixes = 'JKLMNOPQ'> suffix = 'ack'>> for letter in prefixes:>  if letter == ('O') or ('Q'):>   print letter + 'u' + suffix> 

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-14 Thread Joseph Quigley
if letter == 'O': >print letter + 'u' + suffix >elif 'Q': >print letter + 'u' + suffic >else: >print letter + suffix > >Do you see? The == "binds more tightly" than the or. And, in python, 'Q' is >considered True for the purposes of tests. > >So this is what happens: > prefix

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-14 Thread joe_schmoe
Joseph Quigley wrote: if letter == 'O': >print letter + 'u' + suffix >elif 'Q': >print letter + 'u' + suffic >else: >print letter + suffix > >Do you see? The == "binds more tightly" than the or. And, in python, 'Q' is >considered True for the purposes of tests. > >So t

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-14 Thread Brian van den Broek
Joseph Quigley said unto the world upon 2005-04-14 10:46: >Do you see? The == "binds more tightly" than the or. And, in python, 'Q' is >considered True for the purposes of tests. >What you can do instead is this: > >for letter in prefixes: >if letter in ['O', 'Q']: >print le