-4
l = len(input("tell me your name!"))
if l > 18:
print("Please enter name with less than 18 letters")
else:
print(input("tell me your name!"))

#after getting the name as input, the length of the name with less than 18 letters have to be displayed else ask user to enter the name with less than 18 characters.

Raanij
  • 1

1 Answers1

2

You need a while loop, that will ask a name until it satisfies the length constraint

name = input("tell me your name: ")
while len(name) >= 18:
    print("Please enter name with less than 18 letters")
    name = input("tell me your name: ")

print("Nice, your name is", name)
azro
  • 53,056
  • 7
  • 34
  • 70