What is the expected output of the following code?
def func(data):
for d in data[::2]:
yield d
for x in func(‘abcdef’):
print(x, end=”)
A . bdf
B. An empty line.
C. abcdef
D. ace
Answer: D
Explanation:
Topics: def yield for print() with end parameter list slicing
Try it yourself:
def func(data):
for d in data[::2]:
yield d
for x in func(‘abcdef’):
print(x, end=”) # ace
The generator function will return every second element of the passed data.
Latest PCEP-30-02 Dumps Valid Version with 124 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund