From 1b7aec35c43360ed1ec699458cc103e3223aac14 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 11 Oct 1999 22:15:41 +0000 Subject: [PATCH] Fix PR#31 -- zfill() mishandles empty string. --- Lib/string.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/string.py b/Lib/string.py index 92158ee9d37..e449c207656 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -475,7 +475,7 @@ def zfill(x, width): n = len(s) if n >= width: return s sign = '' - if s[0] in ('-', '+'): + if s[:1] in ('-', '+'): sign, s = s[0], s[1:] return sign + '0'*(width-n) + s