sayberrrr / oct-10

0 stars 0 forks source link

Ok ra #1

Open Oning20 opened 3 weeks ago

Oning20 commented 3 weeks ago

data = []

def show_all_data(): if len(data) == 0: print("No data to display.") else: for i, item in enumerate(data): print(f"{i+1}. {item}")

def add_single_data(): new_data = input("Enter new data: ") data.append(new_data) print("Data added successfully!")

def add_multiple_data(): num_data = int(input("Enter the number of data entries: ")) for i in range(num_data): new_data = input(f"Enter data {i+1}: ") data.append(new_data) print("Data added successfully!")

def delete_data(): if len(data) == 0: print("No data to delete.") return

show_all_data()

index_to_delete = int(input("Enter the index of the data to delete: ")) - 1 if index_to_delete < 0 or index_to_delete >= len(data): print("Invalid index.") else: del data[index_to_delete] print("Data deleted successfully!")

def delete_all_data(): data.clear() print("All data deleted!")

def update_data(): if len(data) == 0: print("No data to update.") return

show_all_data()

index_to_update = int(input("Enter the index of the data to update: ")) - 1 if index_to_update < 0 or index_to_update >= len(data): print("Invalid index.") else: new_data = input("Enter the new data: ") data[index_to_update] = new_data print("Data updated successfully!")

while True: print("\nMenu") print("Press [1] SHOW ALL DATA") print("Press [2] ADDED SINGLE DATA") print("Press [3] ADD MULTIPLE DATA") print("Press [4] DELETE") print("Press [5] DELETE ALL DATA") print("Press [6] UPDATE DATA")

choice = input("Enter your choice: ")

if choice == '1': show_all_data() elif choice == '2': add_single_data() elif choice == '3': add_multiple_data() elif choice == '4': delete_data() elif choice == '5': delete_all_data() elif choice == '6': update_data() else: print("Invalid choice.")