I'm new to programming, and I was trying to build this birthday reminder app without following a specific tutorial, but rather trying to figure it out by myself, but I am stuck.
The first function adds birthdays to .txt file, no problem. But with the second, whether I try to retrieve birthday data from birthday_dict or from the file, the function just doesn't run.
For the second function, I tried to adjust this https://www.geeksforgeeks.org/birthday-reminder-application-python/, but it still doesn't work.
If anybody can help me with that, it would be great. Thanks!
import datetime
from datetime import date, timedelta
birthday_dict = {}
def add_to_log():
name = input("Name: ")
date_str = input("Birthday (day/month) :")
birthday_dict.update({name: date_str})
with open('./venv/birthday_log.txt', mode='a') as birthday_log:
file = birthday_log.write(f'\n {name}:{date_str}')
print ('Birthday added!')
def reminder():
file = open('birthday_log.txt', 'r')
today = date.today()
today.strftime("%d/%m")
flag = 0
for line in file:
if today in file:
line = line.split(':')
flag = 1
print (f'Today is {line[1]}\'s birthday!')