Jan-08-2022, 12:59 AM
@bowlofred is correct. Remove the loop and you code performs as expected.
#!/usr/bin/python3 list_item_two = ['apples', 'oranges', 'pears', 'apricots'] list_item_two.append("celery") print("ADD (1) or REMOVE (2) elements\n") user_input = input("> ") if user_input == "1": print("Add Element to List") special_val = "add" elif user_input == "2": print("Remove Element to List") special_val = "remove" i = 1
Output:ADD (1) or REMOVE (2) elements
> 1
Add Element to List
1 fruit of type: apples
2 fruit of type: oranges
3 fruit of type: pears
4 fruit of type: apricots
5 fruit of type: celery
Length of elements: 5
What element to add? grapes
Now the list is: ['grapes', 'apples', 'oranges', 'pears', 'apricots', 'celery']