hey guys, im trying to get this program done for class. this is the assignment:

For this assignment, you will write a program that uses a method called displayMenu to display a menu like the following:

Enter 1 to convert a string to uppercase

Enter 2 to convert a string to lowercase

Enter 3 to count the number of words in a string

Enter 4 to count the number of vowels in a string

Enter 5 to exit

After the user enters their choice, ask them to enter the string. Call the variable user_string, and use the len() method to prevent the user from entering an empty string. The user should enter a new string every time they make another choice. The program should loop until the user enters 5 to exit. Use the format() method to concatenate the output for display after each choice. The display should show the user’s original string and the result of their choice in a neat and meaningful manner.

For choice 1, use the upper() method to convert the string to uppercase. For choice 2, you should use the lower() method. For choice 3, use the split() method to split the string on spaces and store it in a list called user_list. Use the len() method to get the length of the list. For choice 4 you will need to create a variable called count to store the number of vowels in. You will need to make sure that you count upper and lowercase vowels by using the upper() or lower() method. Use a variable called vowels to store the vowels in. You will need a for loop to iterate through the user’s string and examine each character to determine exactly how many vowels are contained in the string. Inside of the for loop, use an if statement that contains the find() method to check for the characters contained in the vowels variable in the user’s string.

This is the program that I have written so far. It runs only until you go to enter your choice, and i'm so confused. I don't know where to go from here or how to fix it.

#Variables
user_string = 0
#Enter the menue and choices
def main():
displayMenu()
choice = int(input('Enter your choice:'))
while (choice != 5):
    if(choice == 1):
        upper()
    elif(choice == 2):
        lower()
    elif(choice == 3):
        split()
    elif(choice == 4):
        vowels()
    elif(choice == 5):
        print('Thank you. Goodbye!')
    else:
        print('Incorrect entry, please try again.')
    displayMenu()
    choice = int(input('Enter your choice:'))
    #Allow user to enter string
    user_string = input('Enter a string: ')

#Functions
def displayMenu():
    print('Enter 1 to convert a string to uppercase:')
    print('Enter 2 to convert a string to lowercase:')
    print('Enter 3 to count the number of words in a string:')
    print('Enter 4 to count the number of vowels in a string:')
    print('Enter 5 to exit:')

def upper():
print(user_string.upper())

def lower():
print(user_string.lower())

def split():
words = user_string.split()
wordCount = len(words)
print('The total word count is %s' % wordCount)

main()

Everything regarding the menu is usually in the same function

def displayMenu():
    print('Enter 1 to convert a string to uppercase:')
    print('Enter 2 to convert a string to lowercase:')
    print('Enter 3 to count the number of words in a string:')
    print('Enter 4 to count the number of vowels in a string:')
    print('Enter 5 to exit:')

    choice = ""
    while (choice != 5):
        ## what happens when someone enters a letter
        choice = int(input('Enter your choice:'))
        if choice in [1, 2, 3, 4]:
            string_input=get_sring()
        if(choice == 1):
            upper(string_input)
        elif(choice == 2):
            lower(string_input)
        elif(choice == 3):
            split(string_input)
        elif(choice == 4):
            vowels(string_input)
        elif(choice == 5):
            print('Thank you. Goodbye!')
            return  ## <----- exit function
        else:
            print('Incorrect entry, please try again.')

## same thing for a strint
def get string():
    #Allow user to enter string
    while True:  ## infinite loop
        user_string = input('Enter a string: ')
        if len(user_string):  ## not an empty string
            return user_string
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.