feat: P-1.30 completed and comments added
This commit is contained in:
+11
-3
@@ -16,8 +16,16 @@ def count_steps():
|
|||||||
break
|
break
|
||||||
# Handle ValueError and print error message
|
# Handle ValueError and print error message
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print('Invalid input: Please only enter integers.')
|
print('Invalid input: Please only enter integers.')
|
||||||
|
|
||||||
|
# set 'step_count' variable to count divisions
|
||||||
|
step_count = 0
|
||||||
|
# iterate divisions over 'current_value' until it is lower than 2
|
||||||
|
while current_value >= 2:
|
||||||
|
current_value = current_value / 2
|
||||||
|
# add division step to 'step_count'
|
||||||
|
step_count += 1
|
||||||
|
print(step_count)
|
||||||
|
|
||||||
|
|
||||||
count_steps()
|
count_steps()
|
||||||
Reference in New Issue
Block a user