Skip to content

Commit af90e12

Browse files
committed
Added a function to censor banned words
1 parent c8afb00 commit af90e12

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

one_liners.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
# Get back rot-13 version of text you enter
5656
(lambda x, a = "abcdefghijklmnopqrstuvwxyz", b = "ABCDEFGHIJKLMNOPQRSTUVWXYZ": "".join([a[a.index(x[i]) - 13] if x[i] in a else b[b.index(x[i]) - 13] if x[i] in b else x[i] for i in range(len(x))]))(input("Enter text: "))
5757

58+
# Replace banned words in string with a special character
59+
lambda text, words, char = '*': [text := text.replace(word, char * len(word)) for word in words][-1]
60+
5861
# General One-Liner Commands From https://gist.github.com/craigls/2712084
5962
'''
6063
Some useful Python one-liners taken from http://www.reddit.com/r/Python/comments/fofan/suggestion_for_a_python_blogger_figure_out_what/

0 commit comments

Comments
 (0)