[Tutor] Count for loops

D.V.N.Sarma డి.వి.ఎన్.శర్మ dvnsarma at gmail.com
Mon Apr 3 11:42:08 EDT 2017


Sorry. That was  stupid of me. The loop does nothing.




regards,
Sarma.

On Mon, Apr 3, 2017 at 8:44 PM, Alan Gauld via Tutor <tutor at python.org>
wrote:

> On 03/04/17 16:07, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:
> > Modifying the code as shown below may work.
>
> I doubt it.
>
> > with open(file_path) as a:
> >     b = a.read()
> >
> > get_year = input("What year were you born? ")
> >
> > count = 0
> > for year in b:
>
> Once more I ask, what does this loop do?
>
> >     if get_year in b:
> >         count += 1
> > print("Your birth date occurs %s times in PI!" % (count))
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list