0
0
Terraformcloud~10 mins

String functions (join, split, format) in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to join the list of strings with a comma.

Terraform
joined_string = join(",", [1])
Drag options to blanks, or click blank then click option'
Aformat
Bsplit
Cvar.list_of_strings
Dconcat
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name instead of the variable holding the list.
Forgetting to provide the list argument.
2fill in blank
medium

Complete the code to split the string into a list using a space as separator.

Terraform
split([1], var.input_string)
Drag options to blanks, or click blank then click option'
A" "
B","
C"-"
D";"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a comma or other separator instead of a space.
Not quoting the separator string.
3fill in blank
hard

Fix the error in the format function to insert the variable correctly.

Terraform
formatted_string = format("Hello, %s!", [1])
Drag options to blanks, or click blank then click option'
Avar.name[0]
Bvar.name.split
Cvar.names
Dvar.name
Attempts:
3 left
💡 Hint
Common Mistakes
Using an index or method call instead of the variable itself.
Passing a list instead of a string.
4fill in blank
hard

Fill both blanks to join a list with a dash and then split it back into a list.

Terraform
joined = join([1], var.words)
split_list = split([2], joined)
Drag options to blanks, or click blank then click option'
A"-"
B","
D";"
Attempts:
3 left
💡 Hint
Common Mistakes
Using different separators for join and split.
Using commas or semicolons instead of dashes.
5fill in blank
hard

Fill all three blanks to format a string with two variables and then split the result by a space.

Terraform
formatted = format("%s %s", [1], [2])
split_result = split([3], formatted)
Drag options to blanks, or click blank then click option'
Avar.first_name
Bvar.last_name
C" "
D"-"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of variables.
Using wrong separator for split.