Question: modify it to remove the item by index position using the del function (rather than remove) (show me where to add or remove the code
modify it to remove the item by index position using the del function (rather than remove)
(show me where to add or remove the code and show me the after result of the code)
def main(): # Get a list with values stored in it. numbers = get_values() # Display the values in the list. print('The numbers in the list are:') print(numbers) # The get_values function gets a series of numbers # from the user and stores them in a list. The # function returns a reference to the list. def get_values(): # Create an empty list. values = [] # Create a variable to control the loop. again = 'Y' # Get values from the user and add them to # the list. while again.upper() == 'Y': # Get a number and add it to the list. num = int(input('Enter a number: ')) values.append(num) # Want to do this again? print('Do you want to add another number?') again = input('y = yes, anything else = no: ') print # Return the list. return values # Call the main function. main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
