Decided to work on getting getting a user to enter their name, and then printing it out. The code below will allow someone to enter their name with characters, spaces and the period, and will then output Hello and their name. Numerals and special characters will not be accepted and will print a message that states that a valid text name needs to be entered. It will also ensure that the first position of the string is a character, and if the last position is a period will not print the period again, in case they enter something like “John S.”.
full_name = input("Enter your name please: ")
if (full_name[0].isalpha()
and all(x.isalpha() or x.isspace() or x=="." for x in full_name)):
if (full_name[-1] == "."):
print("Hello " + full_name)
else:
print("Hello " + full_name + ".")
else:
print("Please enter a valid text name...")
Code language: Python (python)