Ad

How To Remove 'ing' From Any Word

- 1 answer

I need to remove ing from the ends of words that have ing in them. If a word doesn't have ing in it, then don't do anything and print that.

I've tried some code using input and word - ing but they don't work.

wrd = input("Word: ")
print(wrd - "ing")
Ad

Answer

If you have words like springing or singing, use re:

import re
wrd = input("Word: ")
print(re.sub("ing$", "", wrd))
Ad
source: stackoverflow.com
Ad