ZipStrings
Joins values from two lists by index according to a given format.
python · Common Scripts
Details
| ID | ZipStrings |
|---|---|
| Language | python |
| From Version | 6.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
README
Joining values by index from 2 list according to a given format.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Cortex XSOAR Version | 6.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| list1 | The first list. List must be at same size as list2. |
| format | A format to join strings by, for example- {1}-{2} will take values in the same index of both list, where the {1} will be replaced with the value from list1 and {2} will be replaced with the value from list2. |
| list2 | The second list. List must be at same size as list1. |
Outputs
| Path | Description | Type |
|---|---|---|
| zipped_list | A list of joined values by the format given. | string |
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 """ COMMAND FUNCTION """ def mapper_command(args: Dict[str, Any]) -> CommandResults: format = str(args.get("format", "{1}-{2}")) list1 = argToList(args.get("list1", [])) list2 = argToList(args.get("list2", [])) res = [format.replace("{1}", x).replace("{2}", y) for x, y in zip(list1, list2)] return CommandResults(outputs={"zipped_list": res}) """ MAIN FUNCTION """ def main(): # pragma: no cover try: return_results(mapper_command(demisto.args())) except Exception as ex: demisto.error(traceback.format_exc()) # print the traceback return_error(f"Failed to execute BaseScript. Error: {ex!s}") """ ENTRY POINT """ if __name__ in ("__main__", "__builtin__", "builtins"): main()