Step-by-step explanation:
twainQuotes = ["I have never let my schooling interfere with my education.",
"Get your facts first, and then you can distort them as much as you please.",
"If you tell the truth, you don't have to remember anything.",
"The secret of getting ahead is getting started.",
"Age is an issue of mind over matter. If you don't mind, it doesn't matter. "]
# Print the original array
print("Original array:")
print(twainQuotes)
# Define a function to sort the array alphabetically
def sortArray(array):
array.sort()
return array
# Sort the array and print it
twainQuotes = sortArray(twainQuotes)
print("Sorted array:")
print(twainQuotes)
# Define a function to insert a new quote in the correct position alphabetically
def insertQuote(array, quote):
array.append(quote)
array = sortArray(array)
return array
# Insert a new quote and print the array
twainQuotes = insertQuote(twainQuotes, "Courage is resistance to fear, mastery of fear, not absence of fear.")
print("Array with new quote:")
print(twainQuotes)