Reputation: 41
I can't isolate the problem. The program is supposed to take two integers and convert them to scientific notation, then multiply them. However it prints the scientific notion twice. However it prints the information twice.
def convert(s):
print("You typed " + s)
n=0
for c in s:
n=n+1
if n==1:
print("In scientific notation:"+str(c)+'.', end='')
if n!=1:
print(str(c),end='')
print('X 10^'+str(len(s)-1))
return c
def convert_product(u):
n=0
for c in u:
n=n+1
if n==1:
print("Product in scientific notation "+c+'.', end='')
if n!=1:
print(c, end='')
def main():
s=input("Please input your first number\n")
t=input("Please input your second number\n")
u=str(int(convert(s))*int(convert(t)))
convert(s)
convert(t)
convert_product(u)
print('X 10^' + str(len(s)+len(t)-2))
main()
Upvotes: 4
Views: 110
Reputation: 4897
You are calling convert in this line :
u=str(int(convert(s))*int(convert(t)))
And you are calling convert again on the numbers :
convert(s)
convert(t)
And the convert function is printing. Thus you have dual prints.
Upvotes: 3