[Tutor] Newb Learning Question

taserian taserian at gmail.com
Wed Apr 2 19:28:18 CEST 2008


On Wed, Apr 2, 2008 at 12:50 PM, Jeffrey Dates <kungfukoi at gmail.com> wrote:

> Sorry forgot to post what I had so far:
>
> for code in range(ord("a"), ord("z") +1):
>     if code == ord("m"):
>         print chr(code +1)
>
> Now, this solves for the first letter after "M", but doesn't do it via a
> string....
>
> thanks,


Let's think about the problem in pseudocode:

If the first letter in the string comes after m in the alphabet, print that
letter.
Otherwise, if the second letter comes after m in the alphabet, print *that*
letter.
etc. etc.

So what you want is to *iterate* through the characters that make up the
string (from start to end) until you find a character that comes after "m".

Your code above seems to *iterate* through all the characters from "a" to
"z", not the characters of a given string.

See if you can fix that first, then we'll talk about the next step.

Tony R.
aka Taser


>
> Jeffrey Dates
> www.kungfukoi.com
>
>
>
>
>
>
>   On Wed, Apr 2, 2008 at 12:44 PM, Jeffrey Dates <kungfukoi at gmail.com>
> wrote:
>
> > Greetings,
> >
> > I have no previous experience in scripting.  Python is my first
> > language...
> > I'm currently trying to build a logic model for how to 'think' in
> > Python, so please excuse my ignorance.
> >
> > Currently, I'm running through some basic 101 tutorials, to wrap my head
> > around solving problems.
> > I'm looking for some advice on how to solve the following exercise:
> >
> > "Write a program that prints the first letter of a string that comes
> > after 'm' in the alphabet."
> >
> > I hope this is not too elementary.
> >
> > I do understand basic, basic concepts.  iteration, for loops, etc.
> > Just having trouble with syntax, and how to format my logic.
> >
> > thank you in advance for any help or examples.
> >
> > Jeffrey Dates
> > www.kungfukoi.com
> >
> >
> >
> >
> >
> >
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080402/7da29948/attachment.htm 


More information about the Tutor mailing list