Skip to content

Instantly share code, notes, and snippets.

@pdbartsch
Created February 7, 2019 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdbartsch/9d71fe31d23aa9f0b22307bed9c1dac6 to your computer and use it in GitHub Desktop.
Save pdbartsch/9d71fe31d23aa9f0b22307bed9c1dac6 to your computer and use it in GitHub Desktop.
'''
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.
'''
import random
a = random.sample(range(1, 100), 15)
def listends(a):
print('',a,'\n',[a for a in [a[0], a[-1]]])
listends(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment