Python Practice › String Programs › Program 97

Add "ly" after "ing"

EasyString Programs · 97 of 106

Write a Python program to add “ly” if a string ends with “ing”, otherwise add “ing”.

Advertisement
Input
"winning", "play"
Output
winningly
playing

Approach

  1. endswith("ing") decides which suffix to add.

Solution

Python
for word in ["winning", "play"]:    print(word + ("ly" if word.endswith("ing") else "ing"))
Output
winningly
playing
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs