I want solution for the following code using generators | Sololearn: Learn to code for FREE!

0

I want solution for the following code using generators

given code: even=[2*i for i in range(10**100)] This will give Memoryerror I want solution for this using Generators.

8/7/2020 8:37:07 PM

Gaurav H. Mehare

4 Answers

New Answer

+4

Use round brackets😉

+3

# generator def even(): x = 0 while True: yield x*2 x += 1 gen = even() for i in range(10): print(next(gen))

+1

Thank you Jan Markus

+1

gaurav even=(2*i for i in range(10**100)) is a generator