Skip to content

Commit 0b177fe

Browse files
committed
ohnoo
1 parent 3577459 commit 0b177fe

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

76.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Write a Python program to find the first appearance of the substring 'too' and 'good' from a given string. If 'good' follows the 'too', replace the whole 'too'' good' substring with 'excellent' and print the resulting string. If the above does not appear, print the string as it is.
2+
# Sample Input Sample Output
3+
# The book is not too good! The book is not excellent!
4+
# This book is good too! This book is good too!
5+
z ='This book is too good too read !'
6+
k = 'too'
7+
m = 'good'
8+
p = ''
9+
count = 0
10+
p = z.split()
11+
lst = []
12+
for i in p:
13+
lst.append(i)
14+
15+
for i in range(len(lst)):
16+
if lst[i] == k:
17+
count += 1
18+
if count <= 1 and lst[i+1] == m:
19+
lst[i] = ''
20+
lst[i+1] = 'excellent'
21+
else:
22+
lst = lst
23+
24+
for we in lst:
25+
if we == '':
26+
lst.remove(we)
27+
for l in lst:
28+
s = ''.join(str(l))
29+
print(s, end = ' ')
30+

0 commit comments

Comments
 (0)