Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (30 sloc) 741 Bytes
from cs50 import get_string
from sys import argv
words = set()
def main():
if len(argv) != 2:
print("Usage: python bleep.py dictionary")
exit(1)
banned = (argv[1])
file = open(banned, "r")
for line in file:
words.add(line.rstrip("\n"))
file.close()
m = get_string("What is your message? ")
n = m.split()
o = len(n)
for i in n:
if check(i):
for j in i:
print("*", end="")
else:
print(i, end="")
if o == 1:
break
print(" ", end="")
o -= 1
print("\n")
def check(word):
return word.lower() in words
if __name__ == "__main__":
main()
You can’t perform that action at this time.