Would it be cleaner to use `str.translate` for this?