Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6c5dd2c

Browse files
printing a Better Output
1 parent acf3c99 commit 6c5dd2c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

‎embarrassing_story/check_profanity.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ def read_text():
1313
def check_profanity(text_to_check):
1414
url = "http://www.wdylike.appspot.com/?q=" + quote(text_to_check)
1515
with urllib.request.urlopen(url) as connection:
16-
print(connection)
1716
output = connection.read().decode('utf-8')
18-
print(output)
17+
connection.close()
18+
if "true" in output:
19+
print("Profanity Alert!!!")
20+
elif "false" in output:
21+
print("This document has no curse words!")
22+
else:
23+
print("Could not scan the document properly.")
1924
connection.close()
2025

2126
# with urllib.request.urlopen('http://www.python.org/') as f:

‎embarrassing_story/movie_quotes.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ You cant handle the truth. (A Few Good Men)
66

77
I believe everything and I believe nothing. (A Shot in the Dark)
88

9-
fuck

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /