Sarma: thank you so much, I checked your code, it works. However, can
you enlighten me what it exactly does?
I do not understand it (yet). Thank you in advance.

file_path = "C:/Users/Rafael/PythonCode/PiDigits.txt"

with open (file_path) as a:
    b = a.read()

get_year = input("What year were you born? ")

count = 0
b = "3"+b[2:]
n = len(b)
for i in range(n-3):
    if b[i:i+4] == get_year:
        count += 1
print("Your birth date occurs %s times in PI!" % (count))
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
  • Re: [Tutor] C... Alan Gauld via Tutor
    • Re: [Tut... D . V . N . Sarma డి . వి . ఎన్ . శర్మ
      • Re: ... Alan Gauld via Tutor
        • ... D . V . N . Sarma డి . వి . ఎన్ . శర్మ
          • ... Alan Gauld via Tutor
          • ... Alan Gauld via Tutor
            • ... Mats Wichmann
              • ... D . V . N . Sarma డి . వి . ఎన్ . శర్మ
              • ... Alan Gauld via Tutor
              • ... D . V . N . Sarma డి . వి . ఎన్ . శర్మ
              • ... Rafael Knuth
              • ... Alan Gauld via Tutor
              • ... Rafael Knuth
              • ... Alan Gauld via Tutor
              • ... Rafael Knuth
              • ... Marc Tompkins
              • ... boB Stepp
              • ... eryk sun
              • ... Alan Gauld via Tutor
              • ... Mats Wichmann
              • ... Alan Gauld via Tutor

Reply via email to