SimeonTs

SUPyF2 Lists-Advanced-Exercise - 06. Group of 10's

Oct 10th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. """
  2. Lists Advanced - Exercise
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1731#4
  4.  
  5. SUPyF2 Lists-Advanced-Exercise - 06. Group of 10's
  6.  
  7. Problem:
  8. Write a program that receives a list of numbers (string containing integers separated by ", ")
  9. and prints lists with the numbers them into lists of 10's.
  10. Examples:
  11. • The numbers 2 8 4 3 fall into the group under 10
  12. • The numbers 13 19 14 15 fall into the group under 20
  13. For more details, see the examples below
  14.  
  15. Example:
  16. Input                               Output
  17. 8, 12, 38, 3, 17, 19, 25, 35, 50    Group of 10's: [8, 3]
  18.                                    Group of 20's: [12, 17, 19]
  19.                                    Group of 30's: [25]
  20.                                    Group of 40's: [38, 35]
  21.                                    Group of 50's: [50]
  22.  
  23. 1, 3, 3, 4, 34, 35, 25, 21, 33      Group of 10's: [1, 3, 3, 4]
  24.                                    Group of 20's: []
  25.                                    Group of 30's: [25, 21]
  26.                                    Group of 40's: [34, 35, 33]
  27. """
  28. a = [int(number) for number in input().split(", ")]
  29.  
  30. group = 10
  31. group_list = []
  32.  
  33. while True:
  34.     if len(a) == 0:
  35.         break
  36.     for i in a:
  37.         if i <= group:
  38.             group_list += [i]
  39.     print(f"Group of {group}'s: [{', '.join(str(num) for num in group_list)}]")
  40.     for digit in group_list:
  41.         a.remove(digit)
  42.     group += 10
  43.     group_list = []
Add Comment
Please, Sign In to add comment