Skip to content
Advertisement

Print out times that are free and save them in dictionary

I am working on a timetable system and need all the free slots (where the student has no lectures). Right now it prints the entire timetable out. I just need to store all the free slots somewhere. They are showing up as “NaN” on the time table. here is my code.

JavaScript

Expected output would be all the free times printing out. e.g Monday : 11-12, 13-14, 16-17. for each day.

Here is the current output As you can see it is just printing out the timetable. I would like to store all the times where it says NaN

Current output

Advertisement

Answer

Note: This is just an impulse to adapt, you should then be able to make fine tuning on your own.

Based on your update, I now have an idea of what the output should be. To simply output the information in a similar structure, you can iterate over each column of the dataframe if you have set the first column, that keeps the time, as index.

JavaScript

Output

JavaScript

To store these infromation in dict:

JavaScript

Output

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement