For a python Bootcamp, I am working on a program which repeatedly asks for the input of a "name" and prints out it out.
When the user enters "bob", the program must print out "oh, not you, bob!", and print out the shortest and longest names previously entered.
If the user enters anything other than a string of characters (for instance, numbers), program must print out an error message and continue on to ask for a name again.
I don't know how to print out an error message when the user enters an int, a float, or something else than a string like 'romeo"
Please see below my program :
`new_name = ''
while new_name != 'bob':
#Ask the user for a name.
new_name = input("Please tell me someone I should know, or enter 'quit': ")
print('hey', new_name, 'good to see you')
if new_name != 'bob':
names.append(new_name)
largest = None
for name in names:
if largest is None or len(name) > len(largest) :
largest = name
smallest = None
for name in names:
if smallest is None or len(name) < len(smallest) :
smallest = name
print ('oh, not you, bob')
print ("The smallest name previously entered is :", smallest)
print("The largest name previously entered is :", largest)
Thank you very much for your help