I'm trying to figure out how to multiply numbers in python, but I'm having some trouble.
The program should run like this:
Multiple of: 2 (for example)
Enter an upper limit: 10
[2, 4, 6, 8, 10]
The product of the list [2, 4, 6, 8, 10] is: 3840 (this has to be in a separate function and work for any integer)
n = int(input("Multiples of: "))
l = int(input("Upper Limit: "))
def calculation():
for x in range(0, l):
c = x * n
mylist = [c]
print(mylist, end=' ')
calculation()
def listfunction():
productlist = []
for r in productlist:
productlist = [n * l]
print(productlist)
listfunction()
The first problem is that when it runs, it creates more than the l variable specified, the format is also formatted differently, ie [1] [2] [3] instead of [1, 2, 3]
The second part I don't really have an idea on how to do it. I thought it would be similar to what I have like above, but it returns nothing.