Python 3.4 - Unpack List or Tuples
There are multiple ways to separate items in a list or tuple:
You can access a list and the items within it using functions and then have the function do something with those items.
https://www.youtube.com/watch?v=XhXOsgdC9h0
list = ['Yesterday', 'Beer', 8.51] date, item, price = ['Yesterday', 'Beer', 8.51] print(list) print(item)
You can access a list and the items within it using functions and then have the function do something with those items.
def drop_first_last(grades): first, *middle, last = grades avg = sum(middle) / len(middle) print(avg) drop_first_last([65, 75, 65, 88, 99, 34, 22, 10, 99])
https://www.youtube.com/watch?v=XhXOsgdC9h0
Comments