Tried a search but couldn't locate anything. I'm looking for the simplest to replace
if myList and len(myList)>4
with something shorter:
myList = [1,2,3,4,5]
if myList and len(myList)>4:
print myList[4], len(myList)
since
if not myList[4]
doesn't do job.
if len(myList) > 4:is shorter (and equivalent as long asmyListis actually alist) ...if len(myList) > 4. If you need theif myList, it's probbaly because of something else you're not showing here.if myList is not None and len(myList)> 4:Frankly I'd test forNone-ness first and handle that case separately than justif len(myList) <= 4