Created
February 27, 2018 09:02
-
-
Save umair-tp/b45eb08d4e3d8a4172000b7044fffc4a to your computer and use it in GitHub Desktop.
Exercise 12 : Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. For practice, write this code inside a function.
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
| def getBoundaryElements(a): | |
| return [a[0], a[-1]] | |
| if __name__ == '__main__': | |
| a = [5, 10, 15, 20, 2510, 15, 20, 2510, 15, 20, 225] | |
| print getBoundaryElements(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment