Basically, I need a function that will divide n by two and return the number of times it can be done.
Coding so far:
def div(n):
while n >= 0:
n / 2
return n
I know for a fact that I have to use the while loop, but I’m not confident in my third line of coding. What am I doing wrong?
Examples:
>>> div(4)
2
>>> div(7)
2
/ does not perform assignment. Since you’re returning n and not changing its value, I’d think you should start there. Your other hints are = and %.