All strings
Modify the function all_strings
so it returns True
if all the parameters passed are of type string (str
).
Hint: you can use the type
function. Use the run code button to run the example.
Examples:
all_strings('j', 'rmotr', 'Python') # True
all_strings('', 'rmotr', 'Python') # True
all_strings(3, 'rmotr', 'Python') # False
all_strings('hello', None, 'Python') # False
Test Cases
test with none - Run Test
def test_with_none():
assert all_strings('hello', None, 'Python') == False
test with a number - Run Test
def test_with_a_number():
assert all_strings(3, 'rmotr', 'Python') == False
test with all strings - Run Test
def test_with_all_strings():
assert all_strings('j', 'rmotr', 'Python') == True
test with empty string - Run Test
def test_with_empty_string():
assert all_strings('', 'rmotr', 'Python') == True
Solution 1
def all_strings(a, b, c):
if type(a) == str and type(b) == str and type(c) == str:
return True
return False