SimeonTs

SUPyF2 Lists-Advanced-Lab - 02. To-do List

Oct 9th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. """
  2. Lists Advanced - Lab
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1730#1
  4.  
  5. SUPyF2 Lists-Advanced-Lab - 02. To-do List
  6.  
  7. Problem:
  8. You will receive a to-do-notes until you get the command "End".
  9. The notes will be in the format: "{importance}-{value}". Return the list of to-do-notes sorted by importance.
  10. The maximum importance will be 10
  11. Hint
  12. • Use the insert() method
  13.  
  14. Examples:
  15.  
  16. Input:              Output
  17. 2-Walk the dog      ['Drink coffee', 'Walk the dog', 'Work', Dinner']
  18. 1-Drink coffee
  19. 6-Dinner
  20. 5-Work
  21. End
  22. """
  23. commands = []
  24.  
  25. while True:
  26.     command = input()
  27.     if command == "End":
  28.         break
  29.     commands.append(command)
  30.  
  31. notes = ["None"] * len(commands)
  32.  
  33. for note in commands:
  34.     note = note.split("-")
  35.     note_priority = int(note[0])
  36.     note_message = note[1]
  37.     notes.insert(note_priority, note_message)
  38.  
  39. print([note for note in notes if note != "None"])
Add Comment
Please, Sign In to add comment