Exercise: Unpacking a Full Name
The following code contains a mistake. Can you figure out how to extract the first name and last name in one line of code using unpacking? Hint: you'll need to use a string method to transform the string into a list containing two smaller strings.
name = 'Alice Johnson'
# adjust the following line of code
first, last = name
print(first) # expected: Alice
print(last) # expected: Johnson
Python
Setting up Python environment...
Output