Answer to Question #307065 in Python for nowshin

Question #307065

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-07T07:10:57-0500
inputstring=input()
if len(inputstring)<4:
  print(inputstring)
elif len(inputstring)>3:
  if inputstring.endswith('er'):
    print(inputstring[:-2]+'est')
  elif inputstring.endswith('est'):
    print(inputstring)
  else:
    print(inputstring+'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