Keen Learner and Exp... • 2m
Day 10 of learning python as a beginner. Topic: File I/O You guys remeber I once created a to-do list (most probably on day 7)? many amazing people suggested that I should also put a history of tasks. At that time I was not aware about the File I/O in python and today I decided to learn just it. Although I have not finished creating history and then recalling it but I would like to share a quick peek of what I am doing. I guess there may be more ways of creating a history (do tell me if there are) however for now I think the using File I/O may be the current best option. File I/O stands for File input/output and it helps the program to read and write in files it also helps the program remember the user inputs even after the program stops running i.e. by storing the data in a file. As we know programs run on RAM and it is a short term memory by creating file it sends this data to hard disc which is a long term memory (I hope I am correct here do tell me if I have written something wrong). I have used a function for creating history (start from line 24) first I gave a command to open a file (in my case the file has not been created by me it was created by python itself) and then write in it. I have used \n so that every task is created in a new line, as python only adds strings in files (But I have a list) and therefore I used .join() after \n this takes all the items in the list (i.e. our tasks) and creates a string \n breaks this string so that each task is written in a new line. (I hope I was able to explain this clearly). Here's a portion of my code and its result to give you a sneak peek. I acknowledge that this is not yet complete because I also need to make it print when asked (I think I will use the .read() function here). Any suggestions to improve my code are warmly welcomed.
Keen Learner and Exp... • 2m
Day 11 of learning python as a beginner. Topic: creating journal entry program using file I/O. I got a little sidleline from my original plan of editing my to-do list program and created an entirely new program this time for writing a daily journal
See MoreDownload the medial app to read full posts, comements and news.