Ask Question
13 March, 14:49

Implement the function couple, which takes in two lists and returns a list that contains lists with i-th elements of two sequences coupled together. You can assume the lengths of two sequences are the same. Try using a list comprehension.

+3
Answers (1)
  1. 13 March, 16:02
    0
    couple. py

    def couple (s1, s2):

    newlist = []

    for i in range (len (s1)):

    newlist. append ([s1[i], s2[i]])

    return newlist

    s1=[1,2,3]

    s2=[4,5,6]

    print (couple (s1, s2))

    enum. py

    def couple (s1, s2):

    newlist = []

    for i in range (len (s1)):

    newlist. append ([s1[i], s2[i]])

    return newlist

    def enumerate (s, start=0):

    number_Array=[ i for i in range (start, start+len (s)) ]

    return couple (number_Array, s)

    s=[6,1,'a']

    print (enumerate (s))

    print (enumerate ('five',5))
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Implement the function couple, which takes in two lists and returns a list that contains lists with i-th elements of two sequences coupled ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers