Generation

generate functionThu, 22 Dec 2022

Define a function that removes duplicates from an array of numbers and returns it as a result. The order of the sequence has to stay the same.

def distinct(seq): return list(dict.fromkeys(seq)) distinct([1, 2, 2, 3, 4, 4, 5])

Questions about programming?Chat with your personal AI assistant