I'm trying to make it so it will add or multiply based on if the result is over or under 1000. Sorry if my coding is atrocious. I'm still very new to this.
def multi_sol(*num):
product1 = 1
for i in num:
if product1 <= 1000:
product1 *= i
return product1
else:
for i in num:
if product >= 1000:
product1 += i
return product1
result = multi_sol(20, 50)
print("The result is", result)
source https://stackoverflow.com/questions/76551947/how-to-add-and-multiply-arguments
Comments
Post a Comment