Is string

Define a function is_string that receives a variable and if it is a string
returns True and if not returns False.

Hint: Use the isinstance function.


>>> is_string('happy')
>>> is_string(27)

Test Cases

test integer - Run Test

def test_integer():
    assert is_string(27) is False

test string - Run Test

def test_string():
    assert is_string('happy') is True

Solution 1

def is_string(variable):
    if isinstance(variable, str):
        return True
    return False
def is_string(variable): pass