Last active
February 21, 2018 10:56
-
-
Save Hwatwasthat/ce7ec0705e0f7bd0f99ea0e0e625cada to your computer and use it in GitHub Desktop.
List manipulation created by Hwatwasthat - https://repl.it/@Hwatwasthat/List-manipulation
This file contains hidden or 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
| # Initiating variables, list is fixed, value is an input from the console | |
| # and result is an empty list to be filled with results | |
| list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
| value = int(input("what would you like to count to?")) | |
| result = [] | |
| # For loop that compares values in list to value from beginning to end of the list. | |
| # if the value in list is smaller than value then it is appended to the empty list result | |
| for i in range(len(list)): | |
| if list[i] <= value: | |
| result.append(list[i]) | |
| print(result) | |
| [print (result) for result in list if result <= value] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment