How to convert one list into generator

0 votes

I am new in generator concept. I tried to implement lazy execution concept. Can anyone help me with an example how to use list as a generator?

Apr 23, 2020 in Python by akhtar
• 38,260 points
2,544 views

1 answer to this question.

0 votes

Hi@akhtar,

Say, you have one list A. Now convert this list into generator using iter function.

>>>A = [1,2,3,4,5,6]
>>>gen = iter(A)

To check you can use next function.

>>>next(gen)
answered Apr 23, 2020 by MD
• 95,460 points

Related Questions In Python

0 votes
1 answer

How to convert each list item into string in a column of data frame. ?

Hey, To split a string you can use ...READ MORE

answered Feb 5, 2020 in Python by Roshni
• 10,480 points
914 views
0 votes
1 answer
0 votes
1 answer

How to convert list into 2 tuple pair list?

This should work: L = [1, 2, 3, ...READ MORE

answered Nov 4, 2020 in Python by Gitika
• 65,770 points
6,506 views
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
3,458 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,070 views
0 votes
1 answer

How to convert a dataframe into list?

Hi@akhtar, You can convert your dataframe into list. ...READ MORE

answered Apr 25, 2020 in Python by MD
• 95,460 points
711 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP