Can anyone help with the code below. I was wondering whether the if statement should live within the class?. When I have tried this before I can't seem to find a way to print the status using the __str__ method
class Device: def __init__(self, dev_id, dev_status): self.dev_id = dev_id self.dev_status = dev_status def __str__(self): return f'{self.dev_id} - {self.dev_status}' #output from monitoring device output = 'DEVICE,281,3,4' output_split = output.split(',') #should/could this live within the class object? if output_split[3] == '3': status = 'Active' elif output_split[3] == '4': status = 'Inactive' #here I was send output_split[3] rather than status occupancy_sensor1 = Device(output_split[1], status) print(occupancy_sensor1)