Initial Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

LLM Generation

Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

Output

To create a Python function `dedent` that maximally de-dents a string of Python code, we can follow these steps: 1. Split the input string into lines. 2. Identify the minimum indentation level of lines that contain code (i.e., non-blank lines). 3. Remove that level of indentation from all non-blank lines. 4. Join the modified lines back into a single string. Here is a possible implementation:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def dedent(code: str) -> str:
    # Split the code into lines
    lines = code.splitlines()
    
    # Filter out blank lines and get the indentation levels
    non_blank_lines = [line for line in lines if line.strip()]
    if not non_blank_lines:
        return code  # Return as is if there are no non-blank lines
    
    # Determine the minimum indentation level (number of leading spaces)
    min_indent = min(len(line) - len(line.lstrip()) for line in non_blank_lines)
    
    # Remove the minimum indentation level from all non-blank lines
    dedented_lines = []
    for line in lines:
        if line.strip():  # Only modify non-blank lines
            dedented_lines.append(line[min_indent:])  # Remove leading spaces
        else:
            dedented_lines.append(line)  # Keep blank lines as is
    
    # Join the lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage
code = """\
    def example_function():
        print("Hello, World!")
        
        if True:
            print("This is indented.")
    
"""
print(dedent(code))
### Explanation: - The function splits the input string into lines using `splitlines()`. - It collects all non-blank lines and calculates their indentation by determining the number of leading spaces for each line. - It finds the minimum number of leading spaces across all non-blank lines. - It then removes that number of leading spaces from each non-blank line while keeping blank lines unchanged. - Finally, the function joins the modified lines into a single string and returns it. ### Note: This implementation only considers spaces for indentation. If your code might include tabs for indentation, you may want to handle that as well, potentially converting tabs to spaces first or adjusting the logic to account for mixed indentation.

Extract Code

I extracted the following code from that output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def dedent(code: str) -> str:
    # Split the code into lines
    lines = code.splitlines()
    
    # Filter out blank lines and get the indentation levels
    non_blank_lines = [line for line in lines if line.strip()]
    if not non_blank_lines:
        return code  # Return as is if there are no non-blank lines
    
    # Determine the minimum indentation level (number of leading spaces)
    min_indent = min(len(line) - len(line.lstrip()) for line in non_blank_lines)
    
    # Remove the minimum indentation level from all non-blank lines
    dedented_lines = []
    for line in lines:
        if line.strip():  # Only modify non-blank lines
            dedented_lines.append(line[min_indent:])  # Remove leading spaces
        else:
            dedented_lines.append(line)  # Keep blank lines as is
    
    # Join the lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage
code = """\
    def example_function():
        print("Hello, World!")
        
        if True:
            print("This is indented.")
    
"""
print(dedent(code))

Run Code Interpreter

Running the following program:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def dedent(code: str) -> str:
    # Split the code into lines
    lines = code.splitlines()
    
    # Filter out blank lines and get the indentation levels
    non_blank_lines = [line for line in lines if line.strip()]
    if not non_blank_lines:
        return code  # Return as is if there are no non-blank lines
    
    # Determine the minimum indentation level (number of leading spaces)
    min_indent = min(len(line) - len(line.lstrip()) for line in non_blank_lines)
    
    # Remove the minimum indentation level from all non-blank lines
    dedented_lines = []
    for line in lines:
        if line.strip():  # Only modify non-blank lines
            dedented_lines.append(line[min_indent:])  # Remove leading spaces
        else:
            dedented_lines.append(line)  # Keep blank lines as is
    
    # Join the lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage
code = """\
    def example_function():
        print("Hello, World!")
        
        if True:
            print("This is indented.")
    
"""
print(dedent(code))





answer = dedent('''    print("hello")
    print("world")

    if True:
        print("true")
    else:
        print("false")''')
expected = """print("hello")
print("world")

if True:
    print("true")
else:
    print("false")"""
assert answer == expected, f'Wrong answer; got {answer} instead of {expected}'
print('All tests passed')
And got the output:
1
2
3
4
5
6
def example_function():
    print("Hello, World!")</p>
<pre><code>if True:
    print("This is indented.")
</code></pre>
<p>All tests passed

Substring Evaluation

Testing if the previous output contains the string All tests passed: True

Initial Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

LLM Generation

Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

Output

You can create a `dedent` function that removes the common leading whitespace from all non-blank lines in the provided string of Python code. Below is an implementation of such a function:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def dedent(code: str) -> str:
    # Split the input code into lines
    lines = code.splitlines()
    
    # Filter out blank lines
    non_blank_lines = [line for line in lines if line.strip()]

    # Find the minimum indentation level
    if non_blank_lines:
        # Get the leading whitespace of each non-blank line
        indentations = [len(line) - len(line.lstrip()) for line in non_blank_lines]
        min_indent = min(indentations)
    else:
        min_indent = 0

    # Remove the minimum indentation from all non-blank lines
    dedented_lines = [
        line[min_indent:] if len(line) >= min_indent else line
        for line in lines
    ]

    # Join the lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage:
code = """
    def example_function():
        print("Hello, World!")
        
    if True:
        print("This is indented.")
        
"""
print(dedent(code))
### Explanation: 1. **Splitting the Code**: The input string is split into individual lines. 2. **Filtering Non-Blank Lines**: We create a list of non-blank lines to analyze their indentation. 3. **Calculating Minimum Indentation**: We calculate the leading whitespace for each non-blank line and determine the minimum indentation. 4. **De-denting**: We remove the minimum indentation from all lines, ensuring not to go below zero. 5. **Joining Lines**: Finally, we join the modified lines back into a single string and return it. This function will correctly dedent the provided Python code while retaining the overall structure and readability.

Extract Code

I extracted the following code from that output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def dedent(code: str) -> str:
    # Split the input code into lines
    lines = code.splitlines()
    
    # Filter out blank lines
    non_blank_lines = [line for line in lines if line.strip()]

    # Find the minimum indentation level
    if non_blank_lines:
        # Get the leading whitespace of each non-blank line
        indentations = [len(line) - len(line.lstrip()) for line in non_blank_lines]
        min_indent = min(indentations)
    else:
        min_indent = 0

    # Remove the minimum indentation from all non-blank lines
    dedented_lines = [
        line[min_indent:] if len(line) >= min_indent else line
        for line in lines
    ]

    # Join the lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage:
code = """
    def example_function():
        print("Hello, World!")
        
    if True:
        print("This is indented.")
        
"""
print(dedent(code))

Run Code Interpreter

Running the following program:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def dedent(code: str) -> str:
    # Split the input code into lines
    lines = code.splitlines()
    
    # Filter out blank lines
    non_blank_lines = [line for line in lines if line.strip()]

    # Find the minimum indentation level
    if non_blank_lines:
        # Get the leading whitespace of each non-blank line
        indentations = [len(line) - len(line.lstrip()) for line in non_blank_lines]
        min_indent = min(indentations)
    else:
        min_indent = 0

    # Remove the minimum indentation from all non-blank lines
    dedented_lines = [
        line[min_indent:] if len(line) >= min_indent else line
        for line in lines
    ]

    # Join the lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage:
code = """
    def example_function():
        print("Hello, World!")
        
    if True:
        print("This is indented.")
        
"""
print(dedent(code))





answer = dedent('''    print("hello")
    print("world")

    if True:
        print("true")
    else:
        print("false")''')
expected = """print("hello")
print("world")

if True:
    print("true")
else:
    print("false")"""
assert answer == expected, f'Wrong answer; got {answer} instead of {expected}'
print('All tests passed')
And got the output:
1
2
3
4
5
def example_function():
    print("Hello, World!")</p>
<p>if True:
    print("This is indented.")</p>
<p>All tests passed

Substring Evaluation

Testing if the previous output contains the string All tests passed: True

Initial Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

LLM Generation

Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

Output

To create a function `dedent(str)` that removes the common leading whitespace from the lines of a given string (Python code), we can follow these steps: 1. Split the input string into individual lines. 2. Identify the minimum indentation level of non-empty lines. 3. Remove that level of indentation from all non-empty lines. 4. Join the lines back together and return the result. Here is a Python implementation of the `dedent` function:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def dedent(code: str) -> str:
    # Split the input string into lines
    lines = code.splitlines()
    
    # Find the minimum indentation level of non-empty lines
    min_indent = float('inf')
    
    for line in lines:
        stripped_line = line.lstrip()
        if stripped_line:  # Only consider non-empty lines
            current_indent = len(line) - len(stripped_line)
            min_indent = min(min_indent, current_indent)
    
    # Dedent each line by the minimum indent found
    dedented_lines = []
    for line in lines:
        if line.strip():  # Only dedent non-empty lines
            dedented_lines.append(line[min_indent:])
        else:
            dedented_lines.append(line)  # Keep blank lines unchanged
    
    # Join the dedented lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage:
code = """
    def example_function():
        print("Hello, World!")
        
        if True:
            return True
    """
print(dedent(code))
### Explanation: - The function first splits the input string into lines using `splitlines()`. - It then determines the minimum indentation level by checking the leading spaces in each non-empty line. - After finding the minimum indentation, it constructs a new list of lines where each non-empty line is stripped of the minimum indentation. - Finally, it joins the dedented lines back into a single string and returns it. This function will effectively maximize the dedentation while preserving the structure of the code and leaving blank lines untouched.

Extract Code

I extracted the following code from that output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def dedent(code: str) -> str:
    # Split the input string into lines
    lines = code.splitlines()
    
    # Find the minimum indentation level of non-empty lines
    min_indent = float('inf')
    
    for line in lines:
        stripped_line = line.lstrip()
        if stripped_line:  # Only consider non-empty lines
            current_indent = len(line) - len(stripped_line)
            min_indent = min(min_indent, current_indent)
    
    # Dedent each line by the minimum indent found
    dedented_lines = []
    for line in lines:
        if line.strip():  # Only dedent non-empty lines
            dedented_lines.append(line[min_indent:])
        else:
            dedented_lines.append(line)  # Keep blank lines unchanged
    
    # Join the dedented lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage:
code = """
    def example_function():
        print("Hello, World!")
        
        if True:
            return True
    """
print(dedent(code))

Run Code Interpreter

Running the following program:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def dedent(code: str) -> str:
    # Split the input string into lines
    lines = code.splitlines()
    
    # Find the minimum indentation level of non-empty lines
    min_indent = float('inf')
    
    for line in lines:
        stripped_line = line.lstrip()
        if stripped_line:  # Only consider non-empty lines
            current_indent = len(line) - len(stripped_line)
            min_indent = min(min_indent, current_indent)
    
    # Dedent each line by the minimum indent found
    dedented_lines = []
    for line in lines:
        if line.strip():  # Only dedent non-empty lines
            dedented_lines.append(line[min_indent:])
        else:
            dedented_lines.append(line)  # Keep blank lines unchanged
    
    # Join the dedented lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage:
code = """
    def example_function():
        print("Hello, World!")
        
        if True:
            return True
    """
print(dedent(code))





answer = dedent('''    print("hello")
    print("world")

    if True:
        print("true")
    else:
        print("false")''')
expected = """print("hello")
print("world")

if True:
    print("true")
else:
    print("false")"""
assert answer == expected, f'Wrong answer; got {answer} instead of {expected}'
print('All tests passed')
And got the output:
1
2
3
4
5
6
def example_function():
    print("Hello, World!")</p>
<pre><code>if True:
    return True
</code></pre>
<p>All tests passed

Substring Evaluation

Testing if the previous output contains the string All tests passed: True

Initial Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

LLM Generation

Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

Output

To create a function `dedent(str)` that removes excess indentation from a string of Python code, we can follow these steps: 1. Split the string into lines. 2. Identify non-empty lines and determine the minimum indentation level among them. 3. Remove that level of indentation from all lines. 4. Join the lines back into a single string and return it. Here's how you can implement this in Python:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def dedent(code: str) -> str:
    # Split the input code into lines
    lines = code.splitlines()
    
    # Find the minimum indentation level among non-empty lines
    min_indent = None
    for line in lines:
        stripped_line = line.lstrip()
        if stripped_line:  # Only consider non-empty lines
            current_indent = len(line) - len(stripped_line)
            if min_indent is None or current_indent < min_indent:
                min_indent = current_indent
    
    # If there are no non-empty lines, return the original code
    if min_indent is None:
        return code
    
    # Dedent each line by the minimum indentation level found
    dedented_lines = []
    for line in lines:
        if line.strip():  # If the line is not empty
            dedented_lines.append(line[min_indent:])
        else:
            dedented_lines.append(line)  # Keep empty lines as they are
    
    # Join the lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage
code = """
    def example():
        print("Hello, World!")
    
    if True:
        print("This is indented.")
"""

dedented_code = dedent(code)
print(dedented_code)
### Explanation: - The function first splits the input string into individual lines. - It calculates the minimum indentation level of non-empty lines by stripping leading spaces and comparing the lengths. - It then creates a new list of lines, where each line has the minimum indentation removed. - Finally, it joins the lines back together and returns the dedented code. This function preserves the relative indentation of all lines while ensuring that the code is as de-dented as possible.

Extract Code

I extracted the following code from that output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def dedent(code: str) -> str:
    # Split the input code into lines
    lines = code.splitlines()
    
    # Find the minimum indentation level among non-empty lines
    min_indent = None
    for line in lines:
        stripped_line = line.lstrip()
        if stripped_line:  # Only consider non-empty lines
            current_indent = len(line) - len(stripped_line)
            if min_indent is None or current_indent < min_indent:
                min_indent = current_indent
    
    # If there are no non-empty lines, return the original code
    if min_indent is None:
        return code
    
    # Dedent each line by the minimum indentation level found
    dedented_lines = []
    for line in lines:
        if line.strip():  # If the line is not empty
            dedented_lines.append(line[min_indent:])
        else:
            dedented_lines.append(line)  # Keep empty lines as they are
    
    # Join the lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage
code = """
    def example():
        print("Hello, World!")
    
    if True:
        print("This is indented.")
"""

dedented_code = dedent(code)
print(dedented_code)

Run Code Interpreter

Running the following program:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def dedent(code: str) -> str:
    # Split the input code into lines
    lines = code.splitlines()
    
    # Find the minimum indentation level among non-empty lines
    min_indent = None
    for line in lines:
        stripped_line = line.lstrip()
        if stripped_line:  # Only consider non-empty lines
            current_indent = len(line) - len(stripped_line)
            if min_indent is None or current_indent < min_indent:
                min_indent = current_indent
    
    # If there are no non-empty lines, return the original code
    if min_indent is None:
        return code
    
    # Dedent each line by the minimum indentation level found
    dedented_lines = []
    for line in lines:
        if line.strip():  # If the line is not empty
            dedented_lines.append(line[min_indent:])
        else:
            dedented_lines.append(line)  # Keep empty lines as they are
    
    # Join the lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage
code = """
    def example():
        print("Hello, World!")
    
    if True:
        print("This is indented.")
"""

dedented_code = dedent(code)
print(dedented_code)





answer = dedent('''    print("hello")
    print("world")

    if True:
        print("true")
    else:
        print("false")''')
expected = """print("hello")
print("world")

if True:
    print("true")
else:
    print("false")"""
assert answer == expected, f'Wrong answer; got {answer} instead of {expected}'
print('All tests passed')
And got the output:
1
2
3
4
5
def example():
    print("Hello, World!")</p>
<p>if True:
    print("This is indented.")
All tests passed

Substring Evaluation

Testing if the previous output contains the string All tests passed: True

Initial Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

LLM Generation

Query

Write a python function `dedent(str)` that takes as input a string of python code and de-dents it maximally. Lines that are entirely blank don't count.

Output

To create a `dedent` function that removes the minimum amount of leading whitespace from the lines of a given string of Python code, we can follow these steps: 1. Split the input string into individual lines. 2. Identify the leading whitespace for each non-blank line. 3. Determine the minimum amount of leading whitespace among those lines. 4. Strip that amount of whitespace from all non-blank lines. 5. Join the modified lines back into a single string. Here is the implementation of the `dedent` function:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def dedent(s):
    import re
    
    # Split the input string into lines
    lines = s.splitlines()
    
    # Find the minimum indentation level among non-blank lines
    min_indent = None
    for line in lines:
        stripped_line = line.lstrip()
        if stripped_line:  # Only consider non-blank lines
            indent = len(line) - len(stripped_line)
            if min_indent is None or indent < min_indent:
                min_indent = indent
    
    # If there's no indentation found, return the original string
    if min_indent is None:
        return s
    
    # Create a new list of lines with the common indentation removed
    dedented_lines = []
    for line in lines:
        if line.strip():  # Only modify non-blank lines
            dedented_lines.append(line[min_indent:])
        else:
            dedented_lines.append(line)  # Preserve blank lines
    
    # Join the modified lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage:
code = """\
    def example_function():
        print("Hello, World!")
        
        if True:
            print("This is indented.")
            
    """
print(dedent(code))
### Explanation: 1. **Splitting Lines**: We split the input string into separate lines using `splitlines()`. 2. **Finding Minimum Indentation**: We iterate through each line, stripping it of leading whitespace and checking if it's non-blank. We calculate the indentation level and keep track of the minimum indentation found. 3. **Adjusting Lines**: We create a new list of lines where we remove the minimum indentation from all non-blank lines. Blank lines are preserved as they are. 4. **Joining Lines**: Finally, we join the modified lines back into a single string using `'\n'.join()` and return it. This function effectively dedents Python code while preserving the structure of blank lines.

Extract Code

I extracted the following code from that output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def dedent(s):
    import re
    
    # Split the input string into lines
    lines = s.splitlines()
    
    # Find the minimum indentation level among non-blank lines
    min_indent = None
    for line in lines:
        stripped_line = line.lstrip()
        if stripped_line:  # Only consider non-blank lines
            indent = len(line) - len(stripped_line)
            if min_indent is None or indent < min_indent:
                min_indent = indent
    
    # If there's no indentation found, return the original string
    if min_indent is None:
        return s
    
    # Create a new list of lines with the common indentation removed
    dedented_lines = []
    for line in lines:
        if line.strip():  # Only modify non-blank lines
            dedented_lines.append(line[min_indent:])
        else:
            dedented_lines.append(line)  # Preserve blank lines
    
    # Join the modified lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage:
code = """\
    def example_function():
        print("Hello, World!")
        
        if True:
            print("This is indented.")
            
    """
print(dedent(code))

Run Code Interpreter

Running the following program:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def dedent(s):
    import re
    
    # Split the input string into lines
    lines = s.splitlines()
    
    # Find the minimum indentation level among non-blank lines
    min_indent = None
    for line in lines:
        stripped_line = line.lstrip()
        if stripped_line:  # Only consider non-blank lines
            indent = len(line) - len(stripped_line)
            if min_indent is None or indent < min_indent:
                min_indent = indent
    
    # If there's no indentation found, return the original string
    if min_indent is None:
        return s
    
    # Create a new list of lines with the common indentation removed
    dedented_lines = []
    for line in lines:
        if line.strip():  # Only modify non-blank lines
            dedented_lines.append(line[min_indent:])
        else:
            dedented_lines.append(line)  # Preserve blank lines
    
    # Join the modified lines back into a single string
    return '\n'.join(dedented_lines)

# Example usage:
code = """\
    def example_function():
        print("Hello, World!")
        
        if True:
            print("This is indented.")
            
    """
print(dedent(code))





answer = dedent('''    print("hello")
    print("world")

    if True:
        print("true")
    else:
        print("false")''')
expected = """print("hello")
print("world")

if True:
    print("true")
else:
    print("false")"""
assert answer == expected, f'Wrong answer; got {answer} instead of {expected}'
print('All tests passed')
And got the output:
1
2
3
4
5
6
def example_function():
    print("Hello, World!")</p>
<pre><code>if True:
    print("This is indented.")
</code></pre>
<p>All tests passed

Substring Evaluation

Testing if the previous output contains the string All tests passed: True