A yield example from chatgpt

def count_up_to(n): “””Generator that counts from 1 up to n.””” count = 1 while count <= n: yield count count += 1 # Using the generator for number in count_up_to(5): print(number)