Python 38 Programming Tutorial - Unpack List or Tuples

date, item, price = ['December 23, 2015', 'Bread Gloves', 8.51]print(item)

End of semester you wanted to drop first and last quiz grades and average the rest

def drop_first_last(grades):
    first, *middle, last = grades
    avg = sum(middle) / len(middle)
    print(avg)

drop_first_last([65, 76, 98, 65, 67])
drop_first_last([54, 56, 76, 93])

你可能感兴趣的:(Python 38 Programming Tutorial - Unpack List or Tuples)