Skip to content

Instantly share code, notes, and snippets.

@ehedaoo
Created May 1, 2017 06:09
Show Gist options
  • Save ehedaoo/fe79a792062ad87480961d4624d12f50 to your computer and use it in GitHub Desktop.
Save ehedaoo/fe79a792062ad87480961d4624d12f50 to your computer and use it in GitHub Desktop.
Ask the user for a number and return a list that contains only elements from the original list a that are smaller than that number given by the user.
# Ask the user for a number and return a list that contains only elements
# from the original list a that are smaller than that number given by the user.
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
new_list = []
num = input("Enter a number to be compared with: ")
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