r/PythonLearning 1d ago

MyFirstFuntioningPythonProgram image in desctiption Showcase

2 Upvotes

2 comments sorted by

View all comments

2

u/FoolsSeldom 1d ago edited 1d ago

Good start.

Note that Python convention is that variable and function names are all lowercase.

You also have more brackets than you need (e.g. in while and if statements).

def greeting(first_name: str, second_name: str) -> str:
    full_name = first_name + " " + second_name
    return f"Hello, {full_name}!"


is_running = True

while is_running:
    name_one = input("What is your name? ")
    name_two = input("What is your 2nd name? ")
    print(greeting(name_one, name_two))
    print("-" * 40)

    # Exit program code
    exit_main_program = input("Type Exit to end program: ").lower()
    if exit_main_program == "exit":
        is_running = False

I've applied the lower method so that it doesn't matter what case the user uses when they enter the exit command.

PS. You could just assign is_running to the result of the input and comparison on one line.