Skip to content

Instantly share code, notes, and snippets.

@ehedaoo
Created May 1, 2017 05:48
Show Gist options
  • Save ehedaoo/e574e6bd85fd7c4b272dc1f1d3a94ccd to your computer and use it in GitHub Desktop.
Save ehedaoo/e574e6bd85fd7c4b272dc1f1d3a94ccd to your computer and use it in GitHub Desktop.
Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a program that prints out all the elements of the list that are less than 5.
# Take a list, say for example this one:
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
# and write a program that prints out all the elements of the list that are less than 5.
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
new_list = []
num = 5
for i in a:
if i<num:
new_list.append(i)
else:
break
print(new_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment