he-027
0.000
Challenge · difficulty 1/5
# HumanEval/27
Implement a file **`solution.py`** that completes the function below. Keep the given name and signature; your file must define it at module level.
```python
def flip_case(string: str) -> str:
""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
>>> flip_case('Hello')
'hELLO'
"""
```
<!-- imported from OpenAI HumanEval (HumanEval/27) -->
tests/test_he_027.py
# Auto-generated from OpenAI HumanEval HumanEval/27. Do not edit by hand.
from solution import * # noqa: F401,F403 (prompt helpers may be referenced by tests)
from solution import flip_case as candidate
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == ''
assert candidate('Hello!') == 'hELLO!'
assert candidate('These violent delights have violent ends') == 'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS'
def test_he_027():
check(candidate)
Proposed solution
```
def flip_case(string: str) -> str:
""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
>>> flip_case('Hello')
'hELLO'
"""
return string
```Test output (stdout)
F [100%]
=================================== FAILURES ===================================
_________________________________ test_he_027 __________________________________
def test_he_027():
> check(candidate)
test_he_027.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
candidate = <function flip_case at 0x78a9f0c387c0>
def check(candidate):
assert candidate('') == ''
> assert candidate('Hello!') == 'hELLO!'
E AssertionError: assert 'Hello!' == 'hELLO!'
E
E - hELLO!
E + Hello!
test_he_027.py:13: AssertionError
=========================== short test summary info ============================
FAILED test_he_027.py::test_he_027 - AssertionError: assert 'Hello!' == 'hELLO!'
1 failed in 0.02s