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.<div>
<br></div><div>Trung Doan</div><div>==========<br><br><div class="gmail_quote">On Wed, Dec 19, 2012 at 4:40 PM, Brandon Merritt <span dir="ltr"><<a href="mailto:merrittb7@gmail.com" target="_blank">merrittb7@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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 returning 1 or 0, even if I very clearly make sure that I specify at least 4 instances of the digit in my number string:<div>
<br></div><div><div>number = raw_input('Enter a 7-unit number: ')</div><div><br></div><div>digit = raw_input('Enter a single digit: ')</div><div><br></div><div>for i in number:</div><div> count = 0</div>
<div> if i == digit:</div><div> count += 1</div><div> else:</div><div> count = 0</div><div><br></div><div>print count</div><div><br></div><div>Thanks,</div><div>Brandon</div><span class="HOEnZb"><font color="#888888"><div>
<br></div>
<div><div><br></div>-- <br><b><span style="font-size:large">Brandon Merritt</span></b><i><br>(707) 481-1744</i><div><i><br></i></div>
</div></font></span></div></div>
<br>_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br></div>