SimeonTs

SUPyF2 Lists Basics Exercise - 02. Multiples List

Oct 3rd, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. """
  2. Lists Basics - Exercise
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1725#1
  4.  
  5. SUPyF2 Lists Basics Exercise - 02. Multiples List
  6.  
  7. Problem:
  8. Write a program that receives two numbers (factor and count)
  9. and creates a list with length of the given count and contains only elements that are multiples of the given factor.
  10.  
  11. Example:
  12. Input   Output
  13. 2
  14. 5       [2, 4, 6, 8, 10]
  15.  
  16. 1
  17. 10      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  18. """
  19. factor = int(input())
  20. count = int(input())
  21. my_list = []
  22. digit = 1
  23. while True:
  24.     if len(my_list) == count:
  25.         break
  26.     if digit % factor == 0:
  27.         my_list += [digit]
  28.     digit += 1
  29. print(my_list)
Add Comment
Please, Sign In to add comment