Re: [Tutor] need help with python for counter

2012-12-19 Thread bob gailer
On 12/19/2012 12:40 AM, Brandon Merritt wrote: I feel silly, but I'm having the darndest time trying to figure out why this for counter won't work. I know that there is the count method for the string class, but I was just trying to do it the syntactical way to prove myself that I know the very

Re: [Tutor] need help with python for counter

2012-12-19 Thread Alan Gauld
On 19/12/12 05:40, Brandon Merritt wrote: the string class, but I was just trying to do it the syntactical way to prove myself that I know the very basics. Which is not a bad thing. just returning 1 or 0, even if I very clearly make sure that I specify at least 4 instances of the digit in my

Re: [Tutor] need help with python for counter

2012-12-19 Thread Dave Angel
On 12/19/2012 12:40 AM, Brandon Merritt wrote: > I feel silly, but I'm having the darndest time trying to figure out why > this for counter won't work. I know that there is the count method for the > string class, but I was just trying to do it the syntactical way to prove > myself that I know the

Re: [Tutor] need help with python for counter

2012-12-18 Thread शंतनू
On 19/12/12 5:12 PM, Mitya Sirenef wrote: > You can also do: > > count = sum(i==digit for i in number) > > I think this is very clear and short.. Another... import re count = len(re.findall(digit, number)) -- shantanoo ___ Tutor maillist - Tutor@py

Re: [Tutor] need help with python for counter

2012-12-18 Thread DoanVietTrungAtGmail
After incrementing for a little while, if the condition i == digit is not met for the current character, count is reset by the else: branch. Your count variable must feel frustrated like a dog which keeps being yanked back by a cord of length 0 when it tries to get free. Trung Doan == On

Re: [Tutor] need help with python for counter

2012-12-18 Thread Mitya Sirenef
On 12/19/2012 12:40 AM, Brandon Merritt wrote: I feel silly, but I'm having the darndest time trying to figure out why this for counter won't work. I know that there is the count method for the string class, but I was just trying to do it the syntactical way to prove myself that I know the very

[Tutor] need help with python for counter

2012-12-18 Thread Brandon Merritt
I feel silly, but I'm having the darndest time trying to figure out why this for counter won't work. I know that there is the count method for the string class, but I was just trying to do it the syntactical way to prove myself that I know the very basics. As of right now, my script is just returni