Untitled
Anonymous
plain_text
05/26/2022 5:36 AM
620 B
19
Indexable
#!/usr/bin/python3
BDAY_NOT_FOUND = -1
# find() starts at 0, not 1
IDX_OFFSET = 1
READ_ONLY = 'r'
# read pi into a string
with open('pi.txt', READ_ONLY) as fd:
data = fd.read().rstrip()
digits = int(input("How many digits: "))
bday = input("Enter bday [mmddyyyy]: ")
pos = data.find(bday) + IDX_OFFSET
if (pos == BDAY_NOT_FOUND):
print("Your bday can not be found")
else:
print(f"Your birthday is located at position {pos} of pi")Editor is loading...