import pytest def mixstrings(s1, s2): """Given two strings s1 and s2, create and return a new string that contains the letters from s1 and s2 mixed: i.e. s[0] = s1[0], s[1] = s2[0], s[2] = s1[1], s[3] = s2[1], s[4] = s1[2], ... If one string is longer than the other, the extra characters in the longer string are ignored. Example: In []: mixstrings("Hello", "12345") Out[]: 'H1e2l3l4o5' """ # what length to process n = min(len(s1), len(s2)) # collect chars in this list s = [] for i in range(n): s.append(s1[i]) s.append(s2[i]) return "".join(s) def test_mixstrings_basics(): assert mixstrings("hello", "world") == "hweolrllod" assert mixstrings("cat", "dog") == "cdaotg" def test_mixstrings_empty(): assert mixstrings("", "") == "" def test_mixstrings_different_length(): assert mixstrings("12345", "123") == "112233" assert mixstrings("", "hello") == "" if __name__ == "__main__": pytest.main("-v " + __file__)