Kumar Shubham
1 min readSep 3, 2020

--

I am not doing tune_prob_rev = [1/len(tune_list)] for empty lists.

I guess you missed the part where the program checks whether the length of the os.listdir(alarm_path)==0. If it is zero, it asks users to add at least 1 alarm tune to the folder. Unless the user adds the alarm tune (i.e. folder is non-empty), the program would not progress further.

So, only after the program ensures the list is non-empty, it assigns the tune_list = os.listdir(alarm_path) and then only calculate the tune_prob_rev so there would be no such divide by zero errors.

I hope I was successful in explaining it to you!

--

--

Kumar Shubham
Kumar Shubham

Written by Kumar Shubham

SDE @ Wells Fargo | Ex-SWE Intern @ ByteLearn | Student @ IIT BHU | Web Dev | DSA | https://www.linkedin.com/in/shubham1710

No responses yet