KnowledgeBoat Logo

Computer Science

Write a function that receives two string arguments and checks whether they are same-length strings (returns True in this case otherwise False).

Python

Python Functions

8 Likes

Answer

def same_length_strings(str1, str2):
    return len(str1) == len(str2)

s1 = "hello"
s2 = "world"
s3 = "python"

print(same_length_strings(s1, s2)) 
print(same_length_strings(s1, s3))

Output

True
False

Answered By

5 Likes


Related Questions