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.
Examples:
>>> is_string('happy')
True
>>> is_string(27)
False
Solution 1
def is_string(variable):
if isinstance(variable, str):
return True
return False