I'm trying to delete a tuple from my list, I've tried everything people have said but still no luck. I tried two methods, one time it removes the record even if it's not the name I want to remove, and the second doesn't remove at all.
record=[]
newrecord=[]
full_time=""
choice = ""
while (choice != "x"):
print()
print("a. Add a new employee")
print("b. Display all employees")
print("c. Search for an employee record")
print("d. Delete an employee record")
elif choice == "d":
delete = str(input("Enter the name of the employee you would like to remove from the record: "))
for d in record:
if d == delete:
record.remove(delete)
This doesn't remove anything.
If I change it to:
elif choice == "d":
delete = str(input("Enter the name of the employee you would like to remove from the record: "))
record = [n for n in record if delete in record]
It removes all if I do it this way.
Heres how i add to the list
choice = input("Choose an option (a to f) or x to Exit: ")
if choice == "a":
full_name = str(input("Enter your name: ")).title()
job_title = str(input("Enter your job title: ")).title()
while full_time.capitalize() != "Y" or full_time.capitalize() != "N":
full_time=input("Do you work full time (Y/N): ").upper()
if full_time.capitalize() == "Y":
break
elif full_time.capitalize() == "N":
break
break
hourly_rate = float(input("Enter your hourly rate: £"))
number_years = int(input("Enter the number of full years service: "))
record.append((full_name, job_title, full_time, "%.2f" % hourly_rate, number_years))