EX294 Transform data with filters and plugins Practice Question
Given `{{ ['1', '2', '3'] | map('int') | list }}`, what is the result?
⚠ Common exam trap
Candidates often think 'int' is a filter name rather than a Python function passed to `map`, or they may forget that `map` returns a generator that must be converted to a list with the `list` filter to see the result.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
`[1, 2, 3]`
The `map('int')` filter in Ansible/Jinja2 converts each string element in the list to an integer. The `list` filter then materializes the generator into a list, resulting in `[1, 2, 3]`. Option B is correct because this is the standard behavior of the `map` filter with the `int` function.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
An error because 'int' is not a valid filter name.
Why it's wrong here
The 'int' filter exists in Ansible/Jinja2 and converts each string element to an integer, yielding [1, 2, 3]. It is tempting to assume filter names must be predefined elsewhere, but 'int' is a built-in Jinja2 filter, so no error occurs.
- ✓
`[1, 2, 3]`
Why this is correct
The map filter applies the int filter to each element of the list, converting the strings '1', '2' and '3' into integers. The subsequent list filter materialises the generator into an actual list, yielding [1, 2, 3].
- ✗
`['1', '2', '3']` as integers, but stored as strings.
Why it's wrong here
map('int') returns genuine integer objects, so the result is [1, 2, 3]; Ansible does not preserve the original string type after conversion. It is tempting because YAML and Jinja output can render integers without quotes, but it would be correct only if a filter such as map('string') were applied instead.
- ✗
`['1', '2', '3']`
Why it's wrong here
The map('int') filter converts each string element to an integer, so the list contains integers 1, 2 and 3, not the original strings. It is tempting because the input list holds string values, but it would be correct only if map('int') were omitted or replaced with a filter that leaves elements unchanged.
Go deeper
Related to this question
About these practice questions
This EX294 question is part of Courseiva's 392-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This EX294 practice question is part of Courseiva's free Red Hat certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the EX294 exam.