Cody Bable

Generation

generate functionThu, 13 Apr 2023

divide a list into three separate list

def divide(aList): a = [] b = [] c = [] for x in aList: if x < 0: a.append(x) elif x == 0: b.append(x) else: c.append(x) return a, b, c divide([1, 2, -1, 0, -2, 3])

Questions about programming?Chat with your personal AI assistant