Created
May 1, 2017 06:09
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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