From: Guido van Rossum Date: Mon, 11 Oct 1999 22:15:41 +0000 (+0000) Subject: Fix PR#31 -- zfill() mishandles empty string. X-Git-Tag: v1.6a1~827 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b7aec35c43360ed1ec699458cc103e3223aac14;p=python Fix PR#31 -- zfill() mishandles empty string. --- diff --git a/Lib/string.py b/Lib/string.py index 92158ee9d3..e449c20765 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