Skip to content

Instantly share code, notes, and snippets.

@umair-tp
Created February 27, 2018 09:02
Show Gist options
  • Select an option

  • Save umair-tp/b45eb08d4e3d8a4172000b7044fffc4a to your computer and use it in GitHub Desktop.

Select an option

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.
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