Question: Python pls Create a function rep_none. This function has two or more arguments. each will be iterable. The function returns an iterable result that yields

Python pls

Create a function rep_none. This function has two or more arguments. each will be iterable. The function returns an iterable result that yields tuples of the first, second value of all the iterable.

However, if there's nothing iterable then the value should be None. The function keeps yielding tuples until all iterative argument is done. Which point raises the StopIteration exception.

def rep_none:

#This function should be an iterable function

#Do not create any other function. All the work should be done by rep_none

#Do not assume how many arguments, it could be 2, 3 or 4

#Please test all output!

Output example

a = list(rep_none('zwx',[0,1,2]))

print(a)

#should print out [('z', 0), ('w', 1), ('x', 2)]

b = list(rep_none('abcd',[0,1]))

print(b)

#should print out [('a', 0), ('b', 1), ('c', None), ('d',None)]

c = list(rep_none('ab',[1,2,3,4]))

print(c)

#should print out [('a', 1), ('b', 2), (None, 3), (None, 4)]

d = list( zip_None('ab',[1,2,3],'xy' )

print(d)

#should print out [('a', 1, 'x'), ('b', 2, 'y'), (None, 3, None)]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!