Gabriel Genellina wrote:
En Mon, 16 Jun 2008 22:51:30 -0300, John Salerno <[EMAIL PROTECTED]> escribió:
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 "Lear
En Mon, 16 Jun 2008 22:51:30 -0300, John Salerno <[EMAIL PROTECTED]> escribió:
> 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"
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 fo
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
On Jun 17, 6:34 am, Thomas Hill <[EMAIL PROTECTED]> wrote:
> On Jun 15, 6:23 pm, takayuki <[EMAIL PROTECTED]> wrote:
>
> > def hasnolet(avoid):
> > fin = open('animals.txt')
> > for line in fin:
> > word = line.strip()
> > for letter in avoid:
> >
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
On Jun 16, 2:34 pm, Thomas Hill <[EMAIL PROTECTED]> wrote:
> On Jun 15, 6:23 pm, takayuki <[EMAIL PROTECTED]> wrote:
>
> > def hasnolet(avoid):
> > fin = open('animals.txt')
> > for line in fin:
> > word = line.strip()
> > for letter in avoid:
> >
On Jun 15, 6:23 pm, takayuki <[EMAIL PROTECTED]> wrote:
> def hasnolet(avoid):
> fin = open('animals.txt')
> for line in fin:
> word = line.strip()
> for letter in avoid:
> if letter in word:
> b
On Jun 16, 7:17 am, Paul Hankin <[EMAIL PROTECTED]> wrote:
> On Jun 16, 2:35 pm, takayuki <[EMAIL PROTECTED]> wrote:
>
>
>
> > def hasnolet2(avoid):
> > fin = open('animals.txt')
> > for line in fin:
> > word = line.strip()
>
> > length = len(avoid)
> >
"takayuki" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> fin = open('animals.txt')
> for line in fin:
You can write this as:
for line in open('animals.txt'):
#do stuff
Of course, you can't explicitly close the file this way, but that probably
doesn't matter. Another way
"takayuki" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> John: There were two "inchworms" because "c" is in "inchworm" so it
> shouldn't print. Thanks for your detailed description of the for
> loop.
lol, I even sat there looking at the word and said to myself "ok, it doesn't
co
On Jun 16, 2:35 pm, takayuki <[EMAIL PROTECTED]> wrote:
> def hasnolet2(avoid):
> fin = open('animals.txt')
> for line in fin:
> word = line.strip()
>
> length = len(avoid)
> x = 0
> noprint = 0
>
> while length -1 >= x:
>
Thanks to everyone for the excellent advice.
Roy: I did as you suggested and could see after staring at the output
for awhile what was going on. The print statements really helped to
put a little light on things. Yes, I agree that "learning to fish" is
the best way.
John: There were two "inchwo
takayuki wrote:
inchworm
inchworm
P.S. Why does 'inchworm' only print twice? Or is that not the full output?
--
http://mail.python.org/mailman/listinfo/python-list
takayuki wrote:
for letter in avoid:
if letter in word:
break
else:
print word
Take the word 'dog', for example. What the above loop is doing is
basically this:
1
On 09:23, lunedì 16 giugno 2008 takayuki wrote:
> word = line.strip()
Try
word= line.split()
and at the end of the loop add one more print to go to new line.
--
Mailsweeper Home : http://it.geocities.com/call_me_not_now/index.html
--
http://mail.python.org/mailman/listinfo/python-list
In article
<[EMAIL PROTECTED]>,
takayuki <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm studying python via the exellent book "How to think like a python
> programmer" by Allen Downey.
>
> Noob question follows...
>
> animals.txt is a list of animals, each on a separate line: "aardvard,
> bat, cat,
17 matches
Mail list logo