From 6505415f7d22079506c79051ebd5da20b8ecbf96 Mon Sep 17 00:00:00 2001 From: karnem <mikhail.karnevskiy@desy.de> Date: Fri, 17 Jan 2020 18:34:11 +0100 Subject: [PATCH] Check if list is not empty --- xfel_calibrate/calibrate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py index ee22e2fbd..95207dbb5 100755 --- a/xfel_calibrate/calibrate.py +++ b/xfel_calibrate/calibrate.py @@ -478,10 +478,12 @@ def flatten_list(l): :return: Same string or string with first and last entry of a list """ if isinstance(l, list): - if len(l)>1: + if len(l) > 1: return '{}-{}'.format(l[0], l[-1]) - else: + elif len(l) == 1: return '{}'.format(l[0]) + else: + return '{}' else: return str(l) -- GitLab