Python variables live in "scopes" - they are only visible while in scope, not out of it.
Functions got theire own scope - more about this here: Short Description of the Scoping Rules?
Your count
from above the function definition is not the same as the count
inside your function. You can remedy this by returning it from the function (or making it global
- google this method if you like - I would not recommend it).
# python 3.6 -you are probably using 2.x if your input() gives you a number
number = int(input('Pick a number.')) # you need an int here, not a string
count = 0 # this is not the same count as
def powerct(n):
count = 0 # this one is a different count
while n >= 2:
n = n/2 # this is going to be a float in python 3
count += 1
return count
count = powerct(number)
print(count)
should solve your problem.
Edit:
# python 2.7 -realized youre using that by your use of input() giving int not string
number = input("Pick a number.")
count = 0 # this is not the same count as
def powerct(n):
count = 0 # this one is a different count
while n >= 2:
n = n/2
count += 1
return count
count = powerct(number)
print count