Commit 2fbb0c3e authored by Guido van Rossum's avatar Guido van Rossum

Fix PR#31 -- zfill() mishandles empty string.

parent b9f66d85
...@@ -475,7 +475,7 @@ def zfill(x, width): ...@@ -475,7 +475,7 @@ def zfill(x, width):
n = len(s) n = len(s)
if n >= width: return s if n >= width: return s
sign = '' sign = ''
if s[0] in ('-', '+'): if s[:1] in ('-', '+'):
sign, s = s[0], s[1:] sign, s = s[0], s[1:]
return sign + '0'*(width-n) + s return sign + '0'*(width-n) + s
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment