Answer to Question #306781 in Python for ratul

Question #306781

Write a Python program that will ask the user to enter a word as an input.

  • If the length of the input string is less than 4, then your program should print the same string as an output.
  • If the input string’s length is greater than 3, then your program should add "er" at the end of the input string.
  • If the input string already ends with "er", then add "est" instead, regardless of the length of the input string
  • If the input string already ends with "est", then your program should print the same input string as an output
1
Expert's answer
2022-03-06T04:49:39-0500
string=input()
if len(string)<4:
  print(string)
elif len(string)>3:
  if string.endswith('er'):
    print(string[:-2]+'est')
  elif string.endswith('est'):
    print(string)
  else:
    print(string+'er')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS