Advertisement
DiYane

To-do list

Sep 20th, 2023
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. def sort_todo_notes():
  2.     todo_list = []
  3.  
  4.     while True:
  5.         note = input()
  6.  
  7.         if note == "End":
  8.             break
  9.  
  10.         importance, note_text = note.split('-', 1)
  11.         importance = int(importance)
  12.  
  13.         index = 0
  14.         while index < len(todo_list) and importance > int(todo_list[index].split('-', 1)[0]):
  15.             index += 1
  16.  
  17.         todo_list.insert(index, f'{importance}-{note_text}')
  18.  
  19.     result = [note.split('-', 1)[1] for note in todo_list]
  20.  
  21.     return result
  22.  
  23. result = sort_todo_notes()
  24. print(result)
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement