0
#Below is a welcome message to the user. 
print ("Welcome to Smiths Cleaners, offering the best dry-cleaning 
service around!\n")
#Statement to determine if the customers input name is valid
while True:
name=input("What is the customers name? ").lower()
if name.isalpha() or name.split():
    break
print ("invalid input")
print ("\nBelow is the price table for the services available for", name.capitalize() )

I am trying to do it so that if the user inputs anything without a capital beginning, it will change the confirmation of the name with a capital however the major issue which i am having is to show the error if the user inputs a number or character (, or : etc)

Lauren.M
  • 1
  • 2
  • 1
    Please format the code in your post properly. Like this, we can‘t know which statements are supposed to be grouped together inside or after the while loop. – mkrieger1 Apr 04 '18 at 21:17
  • Possible duplicate of [Asking the user for input until they give a valid response](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) – Patrick Artner Apr 04 '18 at 21:35

1 Answers1

0

As others in the comments have suggest, it would help both you and us if you formatted your code properly.

while True:
    name = input("What is the customer's name? ").lower()
    if name.isalpha():
        break
    else:
        print("Invalid input")

Now if I understand your question you want to validate that the first letter of the customer's name is capitalized? Then calling lower before that validation ensures that all letters are lower case.

In this block you can validate that the name isalpha and then check that the first character of the string isupper.

while True:
    name = input("What is the customer's name? ")
    if name.isalpha() and name[0].isupper():
        break
    else:
        # Handle the invalid input (i.e. replace the first
        # character with valid input, ensure that the rest of 
        # subsequent letters are lowercased).
        print("Invalid input")
eric
  • 1,029
  • 1
  • 8
  • 9