hello.py
= input("Please tell me your name: ")
my_name
= len(my_name)
name_length
print(f"Hello {my_name}! Your name is {name_length} characters long")
To get input from the person running your script, you can use the input()
function.
If you pass a string argument to it, it will use that as the “prompt” when asking for input.
hello.py
= input("Please tell me your name: ")
my_name
= len(my_name)
name_length
print(f"Hello {my_name}! Your name is {name_length} characters long")
Terminal/Command Prompt
python hello.py
Please tell me your name: Matt
Hello Matt! Your name is 4 characters long