SimeonTs

SUPyF2 Text-Pr.-More-Ex. - 05. HTML

Oct 27th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. """
  2. Text Processing - More Exercises
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1741#4
  4.  
  5. SUPyF2 Text-Pr.-More-Ex. - 05. HTML
  6.  
  7. Problem:
  8. You will receive 3 lines of input. On the first line you will receive a title of an article.
  9. On the next line you will receive the content of that article.
  10. On the next n lines until you receive "end of comments" you will get the comments about the article.
  11. Print the whole information in html format. The title should be in "h1" tag (<h1></h1>);
  12. the content in article tag (<article></article>); each comment should be in div tag (<div></div>).
  13. For more clarification see the example below
  14.  
  15. Ecamples:
  16. Input:
  17. SoftUni Article
  18. Some content of the SoftUni article
  19. some comment
  20. more comment
  21. last comment
  22. end of comments
  23.  
  24. Output:
  25. <h1>
  26.    SoftUni Article
  27. </h1>
  28. <article>
  29.    Some content of the SoftUni article
  30. </article>
  31. <div>
  32.    some comment
  33. </div>
  34. <div>
  35.    more comment
  36. </div>
  37. <div>
  38.    last comment
  39. </div>
  40. """
  41.  
  42.  
  43. def title(text):
  44.     print(f"<h1>\n    {text}\n</h1>")
  45.  
  46.  
  47. def article(text):
  48.     print(f"<article>\n    {text}\n</article>")
  49.  
  50.  
  51. def comment(text):
  52.     print(f"<div>\n    {text}\n</div>")
  53.  
  54.  
  55. def web_site():
  56.     title(input())
  57.     article(input())
  58.     while True:
  59.         text = input()
  60.         if text == "end of comments":
  61.             break
  62.         comment(text)
  63.  
  64.  
  65. if __name__ == '__main__':
  66.     web_site()
Add Comment
Please, Sign In to add comment