Skip to content

Instantly share code, notes, and snippets.

@rnaeye
Last active September 24, 2017 15:46
Show Gist options
  • Save rnaeye/5c5e65170cceb68d7d1cfff9c6ae1eaa to your computer and use it in GitHub Desktop.
Save rnaeye/5c5e65170cceb68d7d1cfff9c6ae1eaa to your computer and use it in GitHub Desktop.
#!/usr/bin/python
mylist = a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
newList = []
for item in mylist:
if item < 5:
print(item)
newList.append(item)
print(newList)
print("list comprehension:")
L = {x for x in mylist if x < 5}
print(L)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment