I have a text file with some patient information. I want to add a new patient into the file while incrementing the id automatically.
101, Jane Doe, 1978
102, John Doe, 1907
with open('patients.txt', 'a+') as f:
id = int(input('Enter patient ID: '))
name = input('Enter patient name: ')
yob = input('Enter patient year of birth: ')
f.write('str(id) + ',' + name + ',' + yob)
How can I check the last id number in the file and increment it based on that?