You just have to describe the format to python. You are looking for 3 items separated by a comma. The third item is a digit and the second item is a 3 letter month.
*Note: Code is untested
print "You chose to add a new birthday"
with open('birthdays.txt', 'r') as readobj:
filedata = readobj.read()
months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun',
'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
newLine = raw_input("Enter the name and birthday: ")
try:
name, month, day = [x.strip(' \t\n') for x in newLine.split(',')]
assert day.isdigit()
assert month.lower() in months
with open('birthdays.txt', 'a') as writeobj:
writeobj.write(newLine + '\n')
except (AssertionError, ValueError):
print 'Enter the information in Name, MM, DD format' Also seek(0) doesn't work with the file opened in append mode. It always adds it to the end of the file.