For list unless empty in python
Based on the other answers, I think the cleanest solutions are #Handles None return from get_list for item in get_list() or []: pass #do something or the comprehension equiv result = [item*item for item in get_list() or []]