Advertisement
ralphdc09

its102.pr.wk.05.07.num02

Oct 22nd, 2021
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. # define a function that multiply all the numbers in a list
  2. # multiply_list()
  3. def multiply_list(number):
  4.     total = 1
  5.     for x in number:
  6.         total *= x
  7.     return total
  8.  
  9.  
  10. # initialize a list that contains a number element
  11. num_list = (5, 4, 3, 2, 1)
  12. # print the list num_list
  13. print("The list of numbers is: ", num_list)
  14.  
  15. # call function multiply_list() to get the product of the numbers in list
  16. print("The product is: ", multiply_list(num_list))  # this will print the product of the numbers in list num_list
  17.  
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement