From df9fe81e3e849acfde314b34c0408a1801b3383f Mon Sep 17 00:00:00 2001 From: Lipis Date: Thu, 26 Dec 2019 14:39:01 +0200 Subject: [PATCH] Fix formatting and remove unnecessary else. --- snippets/median.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/snippets/median.md b/snippets/median.md index 1717685d6..ddc003a06 100644 --- a/snippets/median.md +++ b/snippets/median.md @@ -11,10 +11,9 @@ Sort the numbers of the list using `list.sort()` and find the median, which is e def median(list): list.sort() list_length = len(list) - if list_length%2==0: - return (list[int(list_length/2)-1] + list[int(list_length/2)])/2 - else: - return list[int(list_length/2)] + if list_length % 2 == 0: + return (list[int(list_length / 2) - 1] + list[int(list_length / 2)]) / 2 + return list[int(list_length / 2)] ``` ```py