Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- 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.
- '''
- lista = [5, 10, 15, 20, 25]
- listb = []
- def firstlast():
- first = lista[0]
- last = lista[-1]
- return print(f'''
- primeiro item: {first}
- último item: {last}
- ''')
- firstlast()
Add Comment
Please, Sign In to add comment