all combinations instead of using if and elifs
Here's my suggestion: create a list of all possible checks and corresponding descriptors; then apply the checks in a list comprehension and select the successful descriptors:
actions = [(self.average_open.get, "Open"), (self.average_low.get, "Low"),\ (self.average_high.get, "High"), (self.average_close.get, "Close"),\ (self.average_volume.get, "Volume")]print("You got " + ", ".join(word for fun,word in actions if fun())
You could use something like this to create your string to be printed:
def createMessage(): switches = [self.average_open.get(), self.average_low.get(), self.average_height.get(), self.average_close.get(), self.average_volume.get()] options = ["Open", "Low", "Height", "Close", "Volume"] gotten = [] for switch, option in zip(switches, options): if switch: gotten.append(option) return "You got " + ", ".join(gotten)