Solution 1

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

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 string - Run Test

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

test integer - Run Test

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