Skip to content

Instantly share code, notes, and snippets.

@kashfifahim
Created September 12, 2022 21:21
Show Gist options
  • Save kashfifahim/a93accb7e2574074d8261cb691eac84d to your computer and use it in GitHub Desktop.
Save kashfifahim/a93accb7e2574074d8261cb691eac84d to your computer and use it in GitHub Desktop.
List with Mixed Data
def solution_algo(input_list):
# if the list has 0 or 1 element, nothing to do
if len(input_list) <= 1:
return input_list
else:
# using a new list to insert elements from input list
w = []
# first getting all the not-NULL elements into the list
for e in input_list:
if e != None:
w.append(e)
# next getting the NULLs to the back of the list
for e in input_list:
if e == None:
w.append(e)
# replacing the input_list with the new list
input_list = w
# returning the list with elements and NULLs
return input_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment