From b9510959d76ac3ab79fa10ca1a98ef647ff8c118 Mon Sep 17 00:00:00 2001 From: santanu94 Date: Sun, 28 Oct 2018 11:24:38 +0530 Subject: [PATCH] Added Python code to move zeros to array end --- HacktoberFestContribute/move_all_zeros_to_array_end.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 HacktoberFestContribute/move_all_zeros_to_array_end.py diff --git a/HacktoberFestContribute/move_all_zeros_to_array_end.py b/HacktoberFestContribute/move_all_zeros_to_array_end.py new file mode 100644 index 000000000..ba169c6b3 --- /dev/null +++ b/HacktoberFestContribute/move_all_zeros_to_array_end.py @@ -0,0 +1,8 @@ +# Contribution from Santanu Bhattacharjee +# My GitHub account - https://github.com/santanu94 + +def move_zero_to_end(array = [5,0,2,0,3,0,4]): + array.sort(key= lambda x: True if x == 0 else False, reverse= False) + return array + +print(move_zero_to_end([0,0,0,2,6,22,5,34,76,'a','tgf',65,0,'c'])) \ No newline at end of file