Skip to content

Instantly share code, notes, and snippets.

@chookity-pokk
Created June 29, 2018 05:46
Show Gist options
  • Save chookity-pokk/66dcb6e737d591b9560b2e018828e560 to your computer and use it in GitHub Desktop.
Save chookity-pokk/66dcb6e737d591b9560b2e018828e560 to your computer and use it in GitHub Desktop.
"""
Python program that prints out list elements less than a certain number
Hank Greenburg
Date: 6/28/2018
"""
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
for element in a:
if element <= 5:
print(element)
#Above is my program and below is the exact solution.
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
num = int(raw_input("Choose a number: "))
new_list = []
for i in a:
if i < num:
new_list.append(i)
print new_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment