Advertisement
defbind_

Human Health Sorter

Aug 20th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. # Human sorter based on their condition >:D
  2. # below this line in the multi line comment is the code I imported
  3. """
  4. class Person:
  5.  
  6.    def __init__(self, name, age, health, gender,):
  7.        self.name = name
  8.        self.age = age
  9.        self.health = health
  10.        self.gender = gender
  11. """
  12.  
  13. from Classes import Person
  14.  
  15. Human1 = Person("Bobby", 12, "clean", "Male")
  16. Human2 = Person("Kermit", 21, "smoker", "Male")
  17. Human3 = Person("Vanessa", 31, "drug addict", "Female")
  18. Human4 = Person("Bobby", 6, "drug addict", "Male")
  19. Human5 = Person("Big PP Boi", 14, "smoker", "Toaster")
  20.  
  21. lists =[Human1, Human2, Human3, Human4, Human5]
  22.  
  23. clean_list = []
  24. smoke_list = []
  25. drug_list = []
  26.  
  27. for output in lists:
  28.     if output.health == "clean":
  29.         clean_list.append(output.name)
  30.     elif output.health == "smoker":
  31.         smoke_list.append(output.name)
  32.     else:
  33.         drug_list.append(output.name)
  34.  
  35. print("List of clean ppl: " + str(clean_list))
  36. print("List of smokers: " + str(smoke_list))
  37. print("List of drug addicts: " + str(drug_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement