Created
January 18, 2020 00:05
-
-
Save yosefsadek/772472a5377d1e2817f15ff4e87fe38d to your computer and use it in GitHub Desktop.
py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file=open("timetable.csv","r") #opens the file | |
day = input(" enter day:") #gets the input from the user | |
found=False #stores whether the day is found in the file, set to False at the beginning | |
for line in file: #reads each line in the file | |
timetable=line.split(",") #splits the line into the timetable list | |
if day == timetable[0]: #checks if the day entered is in element 0 of the list | |
#if it is it prints the timetable referring to the different elements of the list | |
print("On " + timetable[0] + " your lessons are: \n"+ | |
"Period 1 - " + timetable[1] + "\n Period 2 - " + | |
timetable[2] + "\n Period 3 - " + timetable[3] + | |
"\n Period 4 - " + timetable[4] + "\n Period 5 - " + timetable[5]) | |
#sets found to True as a match is found | |
found=True | |
if found==False: #after the loops checks if found if still False | |
#displays a message if it is | |
print("Please enter any day to now timetable") | |
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 6 columns, instead of 7. in line 2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tuesday,3,9,5,2,1 | |
Wednesday,o,i,u,y,t | |
Thursday,;,l,k,j,h,h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment