1. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2012
Posts
66
Rep Power
3

#### Operator Question

Hello, here is my code[CODE]def counternum ():

Code:
```def counternum ():
num1 = int(input('enter your first number:  '))
num2 = int(input('enter your second number: '))
print(num1)
while num1 < num2:
print (num1)
num1= num1*10
print (num1)
return```

how would I make it so that if num1 currently equals 100 and num 2 is 500 that it would throw an error message before it multiplies again to make num1 1000 thanks
2. Code:
```# doctest command line:
# \$ python3 -m doctest p.py

import math

class Log10Error(ValueError):
pass

# mathematically, the test is:
def checker(num1,num2):
return num2 == num1*10**int(round(math.log10(num2/num1)))

def counternum(num1=None,num2=None):
'''
>>> checker(1,1000)
True
>>> checker(88,880)
True
>>> checker(88,1000)
False
>>> counternum(1,1000)
1
1
10
10
100
100
1000
>>> counternum(88,880)
88
88
880
>>> try:
...     counternum(88,1000)
... except Log10Error:
...     print('whoot!')
...
88
88
880
880
whoot!
>>>
'''
if num1 is None:
num1 = int(input('enter your first number:  '))
if num2 is None:
num2 = int(input('enter your second number: '))
print(num1)
while num1 < num2:
print(num1)
num1 *= 10
if num2 < num1:
raise Log10Error('dude/tte, the second number must be the first number times 10 to an integer power')
print(num1)
return```