Simple Python Console Game With Inefficient Code Flow I made a simple program as an exercise in improving my code flow in Python, which does the following:

asks user to input their name
presents them with a choice to either print their name in reverse, or print the number of characters
after the output is printed, the user is asked if they want to &quot;play again&quot;.  if not, exits

Have I done anything especially goofy?  Any low hanging fruit?  Best practice I'm unaware of?
from sys import exit

def userinput():
    print('Enter your name:')
    n = input()
    print('Hello, ' + n + ', would you rather (R)everse or (C)ount the letters of your name?')
    a = input()
    return (a,n)

def choosef(choice,myname):
    while choice not in ['R','C']:
        print(&quot;Only 'R' or 'C' are valid. Try again:&quot;)
        choice = input()
    if choice == 'R':
        print(''.join(reversed(myname)))
    else:
        spaces = 0
        for c in list(myname):
            if c == ' ':
                spaces = spaces + 1
        print('Total # Characters: ' + str(len(myname) - spaces))
    playagain()

def playagain():
    print(&quot;Would you like to play again, (Y)es or any other character to exit?&quot;)
    yn = input()
    if yn == 'Y':
        ui = userinput()
        choosef(ui[0],ui[1])
    else:
        exit()

ui = userinput()
choosef(ui[0],ui[1])
Try to forget everything that you know about the code, and assume that you aren't the author. Imagine yourself to be a third person reading the code, he/she knows nothing about it and just reading it for the first time.
ui = userinput()
choosef(ui[0],ui[1])

Alright, userinput() must take some input and put it into ui. Makes sense, but what is choosef()?.
Naming convention
Use meaningful names for functions and variables. take this example
x = 3.14
y = 24

what is x and y to the reader? Is that the price of something?
pi_value = 3.14
number_of_hours = 24

Ahhh okay, now I know exactly what 3.14 means. So If I use it somewhere the reader will also know what I exactly mean. This is an important part of writing clean code.
Another aspect is the style. There are a few ways I can write user input*
user_input()
USERINPUT()
UserInput()
userinput()

Which one should I follow?
To have a consistent naming convention, python code follows the PEP-8 naming convention. When I say follows, I mean that it is recommended that you should follow it too as other python libraries also use this. It makes the code look cleaner.
Things like functions follow : lower_snake_case
Classes follow: CamelCase
You can read the link for more information.
Taking input in Python
print('Enter your name:')
n = input()

Clearly, you want to display a message to the user before he enters something. This is why the input() function has something called input prompt.
name = input(&quot;Enter your name: &quot;)
You can display the message between the (). This removes the additional line. Also note that I changed n to name for the reasons I mentioned above.
Formatting strings
From your code, I can see that you concatenated strings with + to form meaningful sentences. That works but there is a huge problem when you want to use variables of different types.
name = &quot;Eric&quot;
age = 14
job = &quot;Comedian&quot;
print(&quot;Hello &quot; + name  + &quot;You are &quot; + age + &quot; years old and you are a &quot; + comedian)


TypeError: can only concatenate str (not &quot;int&quot;) to str

Simply use Python 3's f-strings. Place the letter 'f' before &quot;
print(f&quot;Hello {name}, you are {age} years old &quot;)

Cleaner.
return value from userinput()
What you are currently doing is returning a tuple of choice and name. It's better that you keep them as they are because later on, you slice from it just to get them again.
This means you directly do
return name, choice

# Calling the function


name, choice = userinput()


Code structure
Couple of points

Do not ask &quot;Do you want to play again? &quot; in the play_again() function. The reason you called that function should be because the user wants to play again. Move that to a playgame() function which will call user_input() every time the user wants to play the game, and break from the loop only if the user enters 'n' or &quot;no&quot;

spaces = spaces + 1 can be simplified into spaces += 1

Move the part where you count the number of characters into a separate function which will return an integer. So your play_game() function doesn't do anything other than play the game. When you need the characters , number_of_char = character_len( name ).

Use enum for clarity.


An improved version of the code
from enum import Enum

class PrintChoices(Enum):
    number_of_char = 'c'
    reversed_name = 'r'
    exit_choice = 'e'


def find_num_of_char(name):
    return len(name) - name.count(' ') 

def reverse_name(name):
    return name[::-1]

def user_input():
    name = input(&quot;Enter your name: &quot; )
    choice = input(&quot;Would you like to (r)everse your name\n or would you like to print the number of (c)haracters or (e)xit?: &quot;)
    return name, choice

def clear_screen():
    print(chr(27) + &quot;[2J&quot;)

def play_game():
    while True:
        clear_screen()
        name, choice = user_input()
        if choice == PrintChoices.reversed_name.value:
            print(reverse_name(name))
            input(&quot;Press any key to continue...&quot;)
        elif choice == PrintChoices.number_of_char.value:
            print(find_num_of_char(name))
            input(&quot;Press any key to continue...&quot;)
        elif choice == PrintChoices.exit_choice.value:
            break
        else:
            input(&quot;Invalid input, Press any key to continue...&quot;)



play_game()

Note: I have also added print(chr(27) + &quot;[2J&quot;) to clear the screen.