(Aug-15-2020, 12:18 PM)giladal Wrote: of course k is an instance of range(2, n)...no, it's not an instance of range object. because of the loop, it takes the values (int), produced by range, one by one in each iteration of the loop.
you can visualise the execution here: http://www.pythontutor.com/visualize.html
compare
def smallest_factor(n): numbers = range(2, n) print(f'numbers is {type(numbers)}') for k in numbers: print(f'k is {type(k)}') if n % k == 0: return k smallest_factor(33)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs