On 03/04/17 16:42, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:
> Sorry. That was stupid of me. The loop does nothing.
Let me rewrite the code with some different variable names...
>>> with open(file_path) as a:
>>> b = a.read()
with open (file_path) as PI_text:
PI_as_a_long_string = PI_text.read()
>>> for year in b:
for each_char in PI_as_a_long_string:
>>> if get_year in b:
>>> count += 1
if get_year in PI_as_a_long_string:
count += 1
>>> print("Your birth date occurs %s times in PI!" % (count))
if count:
print("Your birth date occurs in PI, I checked, count, "times!")
Aren't meaningful variable names great? We should all do
them more often.
--
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 - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor