Advertisement
SimeonTs

SUPyF2 Objects/Classes-Lab - 02. Party

Oct 18th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. """
  2. Objects and Classes - Lab
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1733#1
  4.  
  5. SUPyF2 Objects/Classes-Lab - 02. Party
  6.  
  7. Problem:
  8. Create a class Party that only has an attribute called people.
  9. The __init__ method should not accept any parameters.
  10. You will be given names of people (on separate lines) until you receive the command "End".
  11. Use the created class to solve this problem. After you receive the end command print 2 lines:
  12. • "Going: {people}" - the people should be separated by comma and space ", "
  13. • "Total: {total_people_going}"
  14. Note: submit all of your code including the class
  15.  
  16. Examples:
  17. Input:      Output:
  18. Peter       End Going: Peter, John, Katy
  19. John        Total: 3
  20. Katy
  21. """
  22.  
  23.  
  24. class Party:
  25.     def __init__(self):
  26.         self.people = []
  27.  
  28.  
  29. party = Party()
  30. while True:
  31.     name = input()
  32.     if name == "End":
  33.         break
  34.     party.people += [name]
  35.  
  36. print(f"Going: {', '.join(party.people)}")
  37. print(f"Total: {len(party.people)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement