Created
September 12, 2022 21:21
-
-
Save kashfifahim/a93accb7e2574074d8261cb691eac84d to your computer and use it in GitHub Desktop.
List with Mixed Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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