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,210 points
808 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,300 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
284 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 3, 2020 in Python by Gitika
• 65,950 points
1,030 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
2,381 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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,366 views
0 votes
0 answers
+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,810 points
1,776 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 24, 2020 in Python by MD
• 95,300 points
150 views
0 votes
1 answer