Assertion error, eventhough my return value is the same
<pre><code>def interleave(s1,s2): #This function interleaves s1,s2 together
    guess = 0
    total = 0
    while (guess &lt; len(s1)) and (guess &lt; len(s2)):
        x = s1[guess]
        y = s2[guess]
        m = x + y
        print ((m),end ="")
        guess += 1
    if (len(s1) == len(s2)):
        return ("")
    elif(len(s1) &gt; len(s2)):
        return (s1[guess:])
    elif(len(s2) &gt; len(s1)):
        return (s2[guess:])

print (interleave("Smlksgeneg n a!", "a ie re gsadhm"))
</code></pre>

<p>For some reason, my test function gives an assertion error eventhough the output is the same as the code below.
Eg - "Smlksgeneg n a!", "a ie re gsadhm" returns "Sam likes green eggs and ham!"
but an assertion error still comes out</p>

<pre><code>def testInterleave():
    print("Testing interleave()...", end="")
    assert(interleave("abcdefg", "abcdefg")) == ("aabbccddeeffgg")
    assert(interleave("abcde", "abcdefgh") == "aabbccddeefgh")
    assert(interleave("abcdefgh","abcde") == "aabbccddeefgh")
    assert(interleave("Smlksgeneg n a!", "a ie re gsadhm") ==
                  "Sam likes green eggs and ham!")
    assert(interleave("","") == "")
    print("Passed!")

testInterleave()
</code></pre>

<p>You are confusing what is printed by interleave() from what is returned by it. The assert is testing the returned value. For example, when s1 and s2 are the same length, your code prints the interleave (on the <code>print((m),end="")</code> line) but returns an empty string (in the line <code>return ("")</code></p>

<p>If you want interleave to return the interleaved string, you need to collect the x and y variables (not very well named if they are always holding characters) into a single string and return that.</p>

python