The task is to find the difference in the products of the digits and sum of digits. For example, an input of 4 5 6
would give 105
. The issue I'm having is dealing with previous iterations. I know it has something to do with the indexes of the list but I'm having difficulty figuring it out. Here's my code:
# find the difference between the product of all digits and sum of all digits
nums = input()
nums = list(nums.split())
def findProduct():
for i in range(len(nums)):
int(nums[i]) *= int(nums[i+1])
findProduct()