Returns a (string, count)-tuple, with leading zeros strippped from the string and counted.
(s)
| 78 | "zero", "minus", "point", ",", "and" |
| 79 | |
| 80 | def zshift(s): |
| 81 | """ Returns a (string, count)-tuple, with leading zeros strippped from the string and counted. |
| 82 | """ |
| 83 | s = s.lstrip() |
| 84 | i = 0 |
| 85 | while s.startswith((ZERO, "0")): |
| 86 | s = re.sub(r"^(0|%s)\s*" % ZERO, "", s, 1) |
| 87 | i = i + 1 |
| 88 | return s, i |
| 89 | |
| 90 | #print zshift("zero one") # ("one", 1) |
| 91 | #print zshift("0 0 seven") # ("seven", 2) |
no outgoing calls
searching dependent graphs…