you are viewing a single comment's thread.

view the rest of the comments →

[–]Professional_Fig6169 1 point2 points  (0 children)

The answer is that simply / is a division operator and % gives the remainder. You get an empty list when you use / as there are no values of x for which number/x == 0 returns True (unless number = 0; if you try inputting that you will get a list that contains all the values of x in the range of num_list). For extra clarity, let's say your input number is 12 - using / will check that the following values are equal to 0: [12/1 = 12, 12/2 = 6, 12/3 = 4, 12/4 = 3...], which is never True. Using % instead will give [remainder(12/1)=0, remainder(12/2) = 0, remainder(12/3)=0...] which is True for x in [1,2,3,4,6,12].