I have a list sList as:
sList = ['12','8','10']
I need the sum of all the elements of sList.
I came across sum() function in jinja2 but it takes attributes etc, and not sure how to use it with a list.
I tried:
- set_fact:
sList:
- '12'
- '8'
- '10'
- set_fact:
sumList: "{{ sum(sList) }}"
- debug: var=sumList
Expected result: sumList = 30, but gets below error:
"msg": "The task includes an option with an undefined variable. The error was: 'sum' is undefined
Please help.
Thanks