Created
November 30, 2017 08:05
-
-
Save azdafirmansyah/dce0897fe3907fdfbc563e8beee8f904 to your computer and use it in GitHub Desktop.
List Ends
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
''' | |
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