I'm curious about how to make code more efficient in Python, I've got to execute an action, which may or may not have a payload attached depending on the length of a list.
Right now, I'm using an if statement to determine if there is a payload. Is there a better or cleaner way to find this?
#If payload, execute action with it
if(len(data) > 1):
action= mec.action(data[1])
#If no payload, then just execute action
else:
action= mec.action()
return action
ifstatement: you don't need those parentheses.