How can I make a tuple out of a list?

Rakib
@rakib asked 2 years agoCan any please explain how can i create tuple out of a list.
3 Answers

Tanvir Hossain (Tanu)
@tanvir1017 answered 2 years agoIn Python, we can use the <yield> keyword to convert any Python function into a Python generator. Yields function similarly to a conventional return keyword. However, it will always return a generator object. A function can also use the <yield> keyword multiple times.
def creating_gen(index): months = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'] yield months[index] yield months[index+2] next_month = creating_gen(3) print(next(next_month), next(next_month))
Loading...