coderz.py

Keep Coding Keep Cheering!

Generators in Python

Generator Function: In Python, a generator is a function that allows you to create an iterator, an object that generates a sequence of values. A generator function is defined using the keyword yield, rather than return. When a generator function is called, it returns a generator object, which can be used to iterate over the […]

January 17, 2023 | python | No comments

yield Keyword in Python

The yield keyword in Python is used in the body of a function like a return statement, but when a function with a yield statement is called, it returns a generator object instead of a single value. The generator can then be iterated over to retrieve the values produced by the yield statement one at […]

January 13, 2023 | python | No comments

Advertisement