SimeonTs

SUPyF2 Text-Processing-Lab - 04. Text Filter

Oct 26th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. """
  2. Text Processing - Lab
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1739#3
  4.  
  5. SUPyF2 Text-Processing-Lab - 04. Text Filter
  6.  
  7. Problem:
  8. Write a program that takes a text and a string of banned words.
  9. All words included in the ban list should be replaced with asterisks "*", equal to the word's length.
  10. The entries in the ban list will be separated by a comma and space ", ".
  11. The ban list should be entered on the first input line and the text on the second input line.
  12.  
  13. Examples:
  14. Input:
  15. Linux, Windows
  16. It is not Linux, it is GNU/Linux. Linux is merely the kernel, while GNU adds the functionality. Therefore we owe it to them by calling the OS GNU/Linux! Sincerely, a Windows client
  17.  
  18. Output:
  19. It is not *****, it is GNU/*****. ***** is merely the kernel, while GNU adds the functionality. Therefore we owe it to them by calling the OS GNU/*****! Sincerely, a ******* client
  20. """
  21. banned_words = input().split(", ")
  22. text = input()
  23. for word in banned_words:
  24.     text = text.replace(word, f"{'*' * len(word)}")
  25. print(text)
Add Comment
Please, Sign In to add comment