Swap names Complete the following function according to its docstring Note: this function should return None. Its job is to modify the list passed as its argument. 1 def swap_name(name_ list: list[str]) -> None: 'name list contains a single person's name 2. 3. Modify name list so that the first name and last name are swapped. 4. >>> name = [ 'John', 'Smith'] >>> swap_name(name) >>> name ['Smith', 'John'] ['John, 8. Andrew" "Gleeson', 'Smith'] >>> name = 10 >>> swap_name (name) 11 >>> name ['Smith', 'Andrew' Gleeson', John'] 12 6700

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.5: Case Studies
Problem 3E
icon
Related questions
Question
Q2
Swap names
Complete the following function according to its docstring
Note: this function should return None. Its job is to modify the list passed as its argument.
1 def swap_name(name_ list: list[str]) -> None:
'name list contains a single person's name
3.
Modify name list so that the first name and last name are swapped.
4
['John", 'Smith ]
>>> name =
>>> swap_name(name)
7.
>>> name
['Smith', 'John']
['John,
8.
Andrew"
"Gleeson', 'Smith']
>>> name =
10
>>> swap_name(name)
11
>>> name
['Smith', 'Andrew'
Gleeson',
John']
12
13
Transcribed Image Text:Swap names Complete the following function according to its docstring Note: this function should return None. Its job is to modify the list passed as its argument. 1 def swap_name(name_ list: list[str]) -> None: 'name list contains a single person's name 3. Modify name list so that the first name and last name are swapped. 4 ['John", 'Smith ] >>> name = >>> swap_name(name) 7. >>> name ['Smith', 'John'] ['John, 8. Andrew" "Gleeson', 'Smith'] >>> name = 10 >>> swap_name(name) 11 >>> name ['Smith', 'Andrew' Gleeson', John'] 12 13
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr