Skip to content

Instantly share code, notes, and snippets.

@azdafirmansyah
Created November 30, 2017 08:05
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 azdafirmansyah/dce0897fe3907fdfbc563e8beee8f904 to your computer and use it in GitHub Desktop.
Save azdafirmansyah/dce0897fe3907fdfbc563e8beee8f904 to your computer and use it in GitHub Desktop.
List Ends
'''
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.
'''
import random
list_data = random.sample(range(15),8)
def new_list(list_original):
return [list_original[0], list_original[-1]]
list_start_end = new_list(list_data)
print(list_data)
print(list_start_end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment