Is there a way i can loop a function with an argument in a class if that argument is not equal to None? I know how to do this with a lot of if loops, but is there another way I can do this?
Here's an example of what I want to do:
class Name:
def __init__(self,name,favfood,favcolour,favsport):
self.name = name
self.favfood = favfood
self.favcolour = favcolour
self.favsport = favsport
henry = Name("Henry","Sushi","Blue",None)
I want a function that prints out all his favourite things, but will skip it if it is None, a for loop for classes pretty much.
Is there a way to have a forloop for every attribute in a class?