newbie question: for loop within for loop confusion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David

    #16
    Re: newbie question: for loop within for loop confusion

    takayuki wrote:
    Paul,
    >
    Thank you for the informative reply.
    >
    Yes, I created the indent problem when manually copying the original
    script when I posted. (I'm using an old laptop to study python and
    posting here using the desktop.)
    >
    Your examples really helped. Last night I played with using a for
    loop instead of a while loop and got it working, but your examples
    really clarified things.
    >
    This loop was particularly interesting because I didn't know the else
    could be attached to the for. Attaching it to the for solved a lot of
    problems.
    >
    for letter in avoid:
    if letter in word:
    break
    else:
    print word
    >
    >
    I've printed out this whole thread and will be playing with your and
    others' solutions.
    >
    I love this one for its conciseness, but will have to play with it to
    get my head around it.
    >
    if not any(letter in word for letter in avoid):
    print word
    >
    Thanks again.
    >
    takayuki
    --

    >
    >
    >
    takayuki,

    Could you post the complete script.
    thanks
    david


    --
    Powered by Gentoo GNU/LINUX


    Comment

    • Gabriel Genellina

      #17
      Re: newbie question: for loop within for loop confusion

      En Mon, 16 Jun 2008 22:51:30 -0300, John Salerno <johnjsal@gmail NOSPAM.comescri bió:
      takayuki wrote:
      >
      >I'm early on in my python adventure so I'm not there yet on the strip
      >command nuances. I'm reading "How to think like a python
      >programmer" first. It's great.
      >>
      >Then "Learning python". I've read parts of Dive into Python and will
      >work through it fully when I'm a little farther along.
      >
      Yeah, I really recommend Learning Python for getting the basics first.
      It's very thorough in that regard. Dive Into Python is *not* for
      beginners. I'm sorry if people disagree, but it's just not.
      Sure, the author himself says so at the very beginning in http://www.diveintopython.org "Dive Into Python is a Python book for experienced programmers."

      --
      Gabriel Genellina

      Comment

      • John Salerno

        #18
        Re: newbie question: for loop within for loop confusion

        Gabriel Genellina wrote:
        En Mon, 16 Jun 2008 22:51:30 -0300, John Salerno <johnjsal@gmail NOSPAM.comescri bió:
        >
        >takayuki wrote:
        >>
        >>I'm early on in my python adventure so I'm not there yet on the strip
        >>command nuances. I'm reading "How to think like a python
        >>programmer" first. It's great.
        >>>
        >>Then "Learning python". I've read parts of Dive into Python and will
        >>work through it fully when I'm a little farther along.
        >Yeah, I really recommend Learning Python for getting the basics first.
        >It's very thorough in that regard. Dive Into Python is *not* for
        >beginners. I'm sorry if people disagree, but it's just not.
        >
        Sure, the author himself says so at the very beginning in http://www.diveintopython.org "Dive Into Python is a Python book for experienced programmers."
        >
        I know, but I just hear so many people recommend that book for people
        who want to learn the language.

        Comment

        Working...