0 of 6 problems solved • 0%

Returning and Unpacking Tuples

6 exercisesEasy

A function can return several related values in a tuple. Assigning the result to two names unpacks a two-item tuple in order.

def ends(word): return (word[0], word[-1]) first, last = ends("lake") # first is "l", last is "e"