Refactored the code by combining a while loop and user input to make the list more interactive and flexible