Skip to content

Instantly share code, notes, and snippets.

@Mulperi
Created July 15, 2021 15:25
Show Gist options
  • Save Mulperi/11d1118b01e0d159d8d1e6682851f804 to your computer and use it in GitHub Desktop.
Save Mulperi/11d1118b01e0d159d8d1e6682851f804 to your computer and use it in GitHub Desktop.
Python generator example
def square_numbers(nums):
for i in nums:
yield(i*i)
mynums = square_numbers([1,2,3])
for num in mynums:
print(num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment