Advertisement
SimeonTs

SUPyF Lists - 01. Sum List Items

Jun 15th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. """
  2. Lists
  3. Проверка: https://judge.softuni.bg/Contests/Practice/Index/924#0
  4.  
  5. 01. Sum List Items
  6.  
  7. Условие:
  8. Write a program, which reads a list of integers, calculates its sum and prints it.
  9. The input consists of a number n (the number of items) + n integers, each as a separate line.
  10. Examples:
  11.  
  12. Input:
  13. 4
  14. 1
  15. 2
  16. 3
  17. 4
  18. Output: 10
  19.  
  20. Input:
  21. 5
  22. 1
  23. 1
  24. 1
  25. 1
  26. 1
  27. Output: 5
  28. Input:
  29. 4
  30. 2
  31. -1
  32. -2
  33. 8
  34. Output: 7
  35. Hints
  36. -First, read the number n.
  37. -Read the integers in a for-loop.
  38. """
  39.  
  40. n = int(input())
  41.  
  42. list_1 = []
  43.  
  44. for entry in range(n):
  45.     list_1 += [int(input())]
  46.  
  47. print(sum(list_1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement