Skip to content

Commit 2d39927

Browse files
Program 16
1 parent 91c0f18 commit 2d39927

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lab Cycle 2/program16.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Program to Add ‘ing’ at the end of a given string.
2+
# If it already ends with ‘ing’, then add ‘ly’
3+
4+
# Function to add 'ing'/'ly' at the end of a given string
5+
def add_ing(str):
6+
if str[-3:] == 'ing': # if the last three characters are 'ing'
7+
return str + 'ly' # add 'ly' to the end of the string
8+
else:
9+
return str + 'ing' # add 'ing' to the end of the string
10+
11+
print("Enter a string: ")
12+
str = input()
13+
print("The string is ",str)
14+
print("The string after adding 'ing'/'ly' is: ", add_ing(str)) # call the function

0 commit comments

Comments
 (0)