Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a function ion2e() that takes a string as a parameter. If the string e

ID: 639613 • Letter: I

Question

Implement a function ion2e() that takes a string as a parameter. If the string ends with 'ion' it returns the initial part of the string (before the 'ion') followed by an 'e' with no extra spaces. If the string does not end with 'ion', including the circumstance in which the string contains 'ion' as a substring, it returns the original string. The following shows several examples of how the function would be used:

ion2e('congratulation')
congratulate
ion2e('marathon')
marathon
ion2e('hyperrational')
hyperrational
ion2e('irradiation')
irradiate

Explanation / Answer

def ion2e(string):
if string[-3:]=='ion':
print string[-3:] + 'e'
else:
print string

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote