On Wednesday 16 March 2011 05:48:14 Tim Morneau wrote:
> You have to add the colon to the end of the statement if this
> is an accurate representation of the statement so:
>
> "for i in range(len(list)):" instead of "for i in
> range(len(list))"
>
It seems to me that it would be simpler to
You have to add the colon to the end of the statement if this is an
accurate representation of the statement so:
"for i in range(len(list)):" instead of "for i in range(len(list))"
On 3/15/2011 2:01 AM, Sachin Kumar Sharma wrote:
BB,
I am getting error on the following syntax while r
--Original Message-
From: python-list-bounces+ramit.prasad=jpmchase@python.org
[mailto:python-list-bounces+ramit.prasad=jpmchase@python.org] On Behalf Of
Chris Rebert
Sent: Tuesday, March 15, 2011 3:18 AM
To: Sachin Kumar Sharma
Cc: python-list@python.org
Subject: Re: newbie question
On Tue, Mar 15, 2011 at 1:01 AM, Sachin Kumar Sharma wrote:
> I am getting error on the following syntax while running in Ipython and
> spyder and I failed to figure out why
>
> for i in range(len(list))
> ^
> SyntaxError: invalid syntax
You forgot the
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,
21 matches
Mail list logo