I'm a beginner and I'm making a note organizer in python. Theres an option to delete any notes but I tried using the del function but that only made it so that when I delete another note it will delete the one after so I resorted to instead of using the del function, I just set it to '' and now I want to delete it before displaying the new found notes.
heres my code:
class Note: def __init__(self): self.notes = [] def create_note(self, new_note): if new_note.lower() != 'out': self.notes.append(new_note) def delete_note(self, note_index): if 0 <= note_index < len(self.notes): self.notes[note_index] = '' else: print('ERROR: Invalid note index.') def display_notes(self): print('Notes\n-----') for index, note in enumerate(self.notes, 1): print(f'Note {index}: {note}')notes = Note()create = input('[Create Notes?]: ').lower()if create == 'yes': c_note = 1 n_note = '' print('Type "out" if you want to stop making notes.') while n_note.lower() != 'out': n_note = input(f'Note {c_note}: ') notes.create_note(n_note) c_note += 1 d_note = input('Delete any Notes?: ').lower() if d_note == 'yes': try: notes_d = int(input('How many notes to delete?: ')) for _ in range(notes_d): w_note = int(input('Which note to delete?: ')) if 1 <= w_note <= len(notes.notes): notes.delete_note(w_note - 1) else: print('ERROR: Invalid note index.') except ValueError: print('ERROR: Invalid input for note index.') notes.display_notes()elif create == 'no': print('Ok.')else: print('ERROR: Not an option.')