View the step-by-step solution to:

Question

Define a function named one_each(...) which receives two lists ( not necessarily of the same length)

and returns a new list containing alternating elements in the two list, starting with the first element of the first list, then the first element of the second list , etc, as many times as there are elements in the shortest list. The extra elements of the longer list are not considered.


As an example, the following code fragment:

print(one_each(["a","b","c","d"],["A","B","C","D","E","F","G","H","I","J","K"]))

should produce the output:

['a', 'A', 'b', 'B', 'c', 'C', 'd', 'D']

Top Answer

The python code can be written using below idea : Create a function one_each() that takes two lists... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question