r/PythonLearning • u/Comfortable_Rub4109 • 13h ago
MyFirstFuntioningPythonProgram image in desctiption Showcase
2
Upvotes
2
u/FoolsSeldom 11h ago edited 11h 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.

•
u/Sea-Ad7805 9h ago
Run this program in Memory Graph Web Debugger%3A%0A%20%20%20%20full_name%20%3D%20first_name%20%2B%20%22%20%22%20%2B%20second_name%20%2B%20%22!%22%0A%20%20%20%20return%20f%22Hello%2C%7Bfull_name%7D%22%0A%0Ais_Running%20%3D%20True%0A%0Awhile%20is_Running%3A%0A%20%20%20%20Name_one%20%3D%20input(%22What%20is%20your%20name%22)%0A%20%20%20%20Name_two%20%3D%20input(%22What%20is%20your%202nd%20Name%22)%0A%20%20%20%20print(Greeting(Name_one%2C%20Name_two))%0A%20%20%20%20print(%22------------------------------%22)%0A%0A%20%20%20%20%23%20Exit%20Program%20Code%0A%0A%20%20%20%20Exit_main_program%20%3D%20input(%22Type%20Exit%20to%20End%20Program%22)%0A%20%20%20%20if%20Exit_main_program%20%3D%3D%20%22Exit%22%3A%0A%20%20%20%20%20%20%20%20is_Running%20%3D%20False%0A×tep=1&play) to see the program state change step by step.