Skip to content

Commit 06b0ba4

Browse files
committed
second commit
add file.close()
1 parent 965e389 commit 06b0ba4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Silocean/0012/Test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import io
2+
3+
file = io.open('filtered_words.txt', 'r')
4+
list = []
5+
for word in file.readlines():
6+
list.append(word.strip('\n'))
7+
8+
print(list)
9+
10+
def isValid(mystr):
11+
result = mystr
12+
for x in list:
13+
if result.find(x) != -1:
14+
result = result.replace(x, '**')
15+
return result
16+
17+
mystr = input("please input a string:")
18+
print (isValid(mystr))
19+
20+
file.close()

0 commit comments

Comments
 (0)