Filter all numeric characters from the string and answer the resulting integer. Answer 0 if no digits are found. If s is already a number, then answer it as rounded int.
(s)
| 297 | return l |
| 298 | |
| 299 | def filterValue2Int(s): |
| 300 | """Filter all numeric characters from the string and answer the resulting |
| 301 | integer. Answer 0 if no digits are found. If s is already a number, then |
| 302 | answer it as rounded int.""" |
| 303 | if isinstance(s, (int, float)): |
| 304 | return int(round(s)) |
| 305 | digits = '0' |
| 306 | for c in s: |
| 307 | if c in '0123456789': |
| 308 | digits += c |
| 309 | return asInt(digits) |
| 310 | |
| 311 | # B O O L E A N |
| 312 |