Saved Bookmarks
| 1. |
WAP to create a list of 20 numbers find the sum of list and print it along with the list properly. |
|
Answer» EVAL(input("Enter 20 ELEMENTS that you want to be added: "))
PRINT() print("Your list of numbers: ", L) s = 0 for i in l: s = s + i print() print(s, "is the SUM of all the elements in the list.") Once the user inputs 20 numbers, a loop is started. The range given is the list, which means it includes all the numbers in the list. The changing variable 'i', takes up all the values and adds it to a sum variable. |
|