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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.