Modify the below code to get the output:

# Checking if a word in user inputs is a palindrome.
def check_palindrome(word):
    palindrome = ""
    for char in word:
        palindrome = char + palindrome
    if palindrome == word:
        print("Wow!! You entered a PALINDORE: ", word)
        return word
    else:
        return False

# Checking if user inputs having special characters.
def check_special_chars(word):
    special_chars = "!@#$%^&*()_+-=:;,.<>?/~`"
    input_special = ""
    for char in word:
        if char in special_chars:
            input_special = input_special + char
    if len(input_special) > 0:
        print("Invalid word: includes SPECIAL characters: ", input_special)
        return word
    else:
        return False

#
def check_bigrams(word):
    bigrams = word.split()
    if len(bigrams) == 2:
        print(f"***** {word} is a bi-gram!! **************")
        return word
    else:
        return False
    
def check_duplicates(input_words):
    duplicate_words = []
    duplicates = {}
    for word in input_words:
        if word not in duplicates:
            duplicates[word] = 1
        else:
            duplicate_words.append(word)
    return duplicate_words

def choice_one():
    input_words = []
    bigrams = []
    invalid_words = []
    palindromes = []
    
    user_input2 = input("Please enter a word OR press ‘space bar’ to exit: ")
    
    while user_input2 != " ":
        print("Please enter a word OR press ‘space bar’ to exit: ", user_input2)
        
        input_words.append(user_input2)
        
        result = check_palindrome(user_input2)
        if result == user_input2:
            palindromes.append(result)
            
        result = check_special_chars(user_input2)
        if result == user_input2:
            invalid_words.append(user_input2)
            
        result = check_bigrams(user_input2)
        if result == user_input2:
            bigrams.append(user_input2)
            
        user_input2 = input("Please enter a word OR press ‘space bar’ to exit: ")
        
    print("*********** Word Entry finished. ******************\n")
    
    return input_words, invalid_words, palindromes, bigrams

def initializing():
    print("*" * 60)
    print("~~~~~~~~~~~~ Text Analytics~~~~~~~~~~~~~~~~~~~~~")
    print("*" * 60)
    print("************* MAIN MENU **********************")
    print("Press/Enter 1 to enter word(s).")
    print("Press/Enter 2 to see the entry summary.")
    print("Press/Enter 3 to see words summary.")
    print("Press/Enter 4 to sort/organize the words.")
    print("Press/Enter 5 to Quit the application.")
    print("*" * 60)

    user_input1 = int(input("Enter the choice: "))

    if user_input1 == 1:
        input_words, invalid_words, palindromes, bigrams = choice_one()   

    elif user_input2 == 2:
        print("*" * 60)
        print("*********** Entry Summary***********************")
        print("*" * 60)
        
        duplicate_words = check_duplicates(input_words)
        
        print(f"You entered total of {len(input_words) - len(invalid_words)} valid words")
        print(f"You entered {len(set(input_words))} unique words")
        print(f"You entered {len(bigrams)} bi-grams: {bigrams}")
        print(f"You entered {len(palindromes)} palindromes: {palindromes}")
        print(f"You entered {len(invalid_words)} INVALID words: {invalid_words}. The words are deemed invalid as they contained following special characters: #, $, !, &, *")
        print(f"You entered {len(duplicate_words)} duplicate words: {duplicate_words}")
        print("\n")
    
    elif user_input2 == 3:
        print("*" * 60)
        print("*********** Words Summary***********************")
        print("*" * 60)
        
        key_value_pairs = {}
        alphabet = "abcdefghijklmnopqrstuvwxyz"
        for word in input_words:
            first_char = word[0:0]
            if first_char in key_value_pairs:
                key_value_pairs[first_char].append(word)
            else:
                key_value_pairs[first_char] = [word]
        for char in alphabet:
            if char in key_value_pairs:
                print(f"The words starting with alphabet [{char}] is/are: {key_value_pairs.get(char)}")
            else:
                print(f"There is No word starting with [{char}]")  
                    
    elif user_input2 == 4:
        print("*" * 60)
        print("~ ~ ~ Enter 1 to alphabetically sort the words by FIRST characters OR \nEnter 2 to sort the words by SECOND characters OR \nEnter 3 to sort the words by LAST characters OR \nENTER 4 to return to the main menu ~ ~ ~")
        print("*" * 60)
        
        user_input3 = int(input("Ener the choice to sort: "))
        while user_input3 != 4:
            if user_input3 == 1:
                print("The words sorted based on their FIRST character are: ", sorted(key_value_pairs.values()))
            
            elif user_input3 == 2:       
                sorted_words = {}
                sorted_input_words = []
                for word in input_words:
                    second_char = word[1:1]
                    if second_char in sorted_words:
                        sorted_words[second_char].append(word)
                    else:
                        sorted_words[second_char] = [word]
                for key, value in sorted(sorted_words.items()):
                    sorted_input_words.append(value)
                print("The words sorted based on their SECOND character are: ", sorted_input_words) 
                
            elif user_input3 == 3:
                sorted_last = {}
                last_sorted_words = []
                for word in input_words:
                    last_char = word[-1:]
                    if last_char in sorted_last:
                        sorted_last[last_char].append(word)
                    else:
                        sorted_last[last_char] = [word]
                for key, value in sorted(sorted_last.items()):
                    last_sorted_words.append(value)                
                print("The words sorted based on their LAST character are: ", last_sorted_words)
                
            elif user_input3 == 4:
                
    
    elif user_input2 == 5:
        print("Good Bye!!!")
            
    else:
        print("Invalid choice, please try again.")

Output:

Press/Enter 1 to enter word(s).
Press/Enter 2 to see the entry summary.
Press/Enter 3 to see words summary.
Press/Enter 4 to sort/organize the words.
Press/Enter 5 to Quit the application.
************************************************

Enter the choice: 1

Please enter a word OR press ‘space bar’ to exit: have

Please enter a word OR press ‘space bar’ to exit: do

Please enter a word OR press ‘space bar’ to exit: say

Please enter a word OR press ‘space bar’ to exit: afefa

Wow!! You entered a PALINDORE: AFEFA

Please enter a word OR press ‘space bar’ to exit: get

Please enter a word OR press ‘space bar’ to exit: make

Please enter a word OR press ‘space bar’ to exit: #$40$!

Invalid word: includes SPECIAL characters: #,$,!  

Please enter a word OR press ‘space bar’ to exit: go

Please enter a word OR press ‘space bar’ to exit: know

Please enter a word OR press ‘space bar’ to exit:  take

Please enter a word OR press ‘space bar’ to exit: see

Please enter a word OR press ‘space bar’ to exit:  good job

Please enter a word OR press ‘space bar’ to exit: #&***&!

Invalid word: includes SPECIAL characters: #,&,*,!

Please enter a word OR press ‘space bar’ to exit: user friendly

Please enter a word OR press ‘space bar’ to exit: come

Please enter a word OR press ‘space bar’ to exit: !!Yahoo!!!

Invalid word: includes SPECIAL characters:!

Please enter a word OR press ‘space bar’ to exit: rotor

Wow!! You entered a PALINDORE: ROTOR

Please enter a word OR press ‘space bar’ to exit: think

Please enter a word OR press ‘space bar’ to exit: look

Please enter a word OR press ‘space bar’ to exit: Too Good

***** Too Good is a bi-gram!! **************

Please enter a word OR press ‘space bar’ to exit: food

Please enter a word OR press ‘space bar’ to exit: Too Good

***** Too Good is a bi-gram!! **************

Please enter a word OR press ‘space bar’ to exit: want

Please enter a word OR press ‘space bar’ to exit: give

Please enter a word OR press ‘space bar’ to exit: use

Please enter a word OR press ‘space bar’ to exit: find

Please enter a word OR press ‘space bar’ to exit: tell

Please enter a word OR press ‘space bar’ to exit: use

Please enter a word OR press ‘space bar’ to exit: ask

Please enter a word OR press ‘space bar’ to exit: work

Please enter a word OR press ‘space bar’ to exit: seem

Please enter a word OR press ‘space bar’ to exit: feel

Please enter a word OR press ‘space bar’ to exit: leave

Please enter a word OR press ‘space bar’ to exit: call

Please enter a word OR press ‘space bar’ to exit: radar

Wow!! You entered a PALINDORE: RADAR

Please enter a word OR press ‘space bar’ to exit: fail

Please enter a word OR press ‘space bar’ to exit:   

 

*********** Word Entry finished. ******************

 
 

************************************************

~~~~~~~~~~~~ Text Analytics~~~~~~~~~~~~~~~~~~~~~

************************************************

************* MAIN MENU **********************

Press/Enter 1 to enter word(s).
Press/Enter 2 to see the entry summary.
Press/Enter 3 to see words summary.
Press/Enter 4 to sort/organize the words.
Press/Enter 5 to Quit the application.
************************************************

Enter the choice: 2

***********************************************

*********** Entry Summary***********************

***********************************************

You entered total of 32 valid words
You entered 28 unique words
You entered 2 bi-grams: good job, Too Good
You entered 3 palindromes: afefa, rotor, radar
You entered 3 INVALID words: #$40$!, #&***&!, !!Yahoo!!! . The words are deemed invalid as they contained following special characters: #, $, !, &, *
You entered 2 duplicate words: Too Good, use
 

************************************************

~~~~~~~~~~~~ Text Analytics~~~~~~~~~~~~~~~~~~~~~

************************************************

************* MAIN MENU **********************

Press/Enter 1 to enter word(s).
Press/Enter 2 to see the entry summary.
Press/Enter 3 to see words summary.
Press/Enter 4 to sort/organize the words.
Press/Enter 5 to Quit the application.
************************************************

Enter the choice: 3

***********************************************

*********** Words Summary***********************

***********************************************

The words starting with alphabet [a] is/are: afefa, ask

There is No word starting with [b]

The words starting with alphabet [c] is/are: call, come

The words starting with alphabet [d] is/are: do

There is No word starting with [e]

The words starting with alphabet [f] is/are: fail, feel, find, food

The words starting with alphabet [g] is/are: get, give, go, good job

The words starting with alphabet [h] is/are: have

There is No word starting with [i]

There is No word starting with [j]

The words starting with alphabet [k] is/are: know

The words starting with alphabet [l] is/are: leave, look

The words starting with alphabet [m] is/are: make

There is No word starting with [n]

There is No word starting with [o]

There is No word starting with [p]

There is No word starting with [q]

The words starting with alphabet [r] is/are: rotor

The words starting with alphabet [s] is/are: say, see, seem

The words starting with alphabet [t] is/are: take, tell, think, Too Good

The words starting with alphabet [u] is/are: use

There is No word starting with [v]

The words starting with alphabet [w] is/are: want, work

There is No word starting with [x]

There is No word starting with [y]

There is No word starting with [z]

 

************************************************

~~~~~~~~~~~~ Text Analytics~~~~~~~~~~~~~~~~~~~~~

************************************************

************* MAIN MENU **********************

Press/Enter 1 to enter word(s).
Press/Enter 2 to see the entry summary.
Press/Enter 3 to see words summary.
Press/Enter 4 to sort/organize the words.
Press/Enter 5 to Quit the application.
************************************************

Enter the choice: 4

~ ~ ~ Enter 1 to alphabetically sort the words by FIRST characters OR Enter 2 to sort the words by SECOND characters OR Enter 3 to sort the words by LAST characters OR ENTER 4 to return to the main menu ~ ~ ~

*********************************************************************

Ener the choice to sort: 3

The words sorted based on their last characters are: afefa

good job, find, food, Too Good, Too Good, come, give, have, leave, make, see, take, use, use, ask, look, think, work, call, fail, feel, tell, seem, do, go, rotor, get, want, know, say, user friendly

************************************************

~~~~~~~~~~~~ Text Analytics~~~~~~~~~~~~~~~~~~~~~

************************************************

************* MAIN MENU **********************

Press/Enter 1 to enter word(s).
Press/Enter 2 to see the entry summary.
Press/Enter 3 to see words summary.
Press/Enter 4 to sort/organize the words.
Press/Enter 5 to Quit the application.
************************************************

Enter the choice: 5

Good Bye!!!