Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Write a function called format_name that accepts a string in the format of first name followed by last name as a parameter, and then returns

Write a function called format_name that accepts a string in the format of first name followed by last name as a parameter, and then returns a string in reverse order (i.e., last name, first name). You may assume that only a first and last name will be given.

For example, format_name("Jared Smith") should return "Smith, Jared"

Hint: The following String Methods will be useful:

# Returns the lowest index in the string where substring is # found. Returns -1 if substring is not found my_string = “eggplant” index = my_string.find(“plant”)      # returns 3 
# Returns all the characters after the specific index my_string = "hello world!" print my_string[1:] # returns "ello world!" print my_string[6:] # returns "world!" 
# Returns all the characters before the specific index my_string = "hello world!" print my_string[:6] # returns "hello" print my_string[:1] # returns "h"

Your program should include:

  • A main method that uses user input to prompt and read a string that contains a person's first name and last name
  • A call to format_name and a print statement that prints the output returned by format_name
  • A call to the main function

Step by Step Solution

3.54 Rating (168 Votes )

There are 3 Steps involved in it

Step: 1

Implement in python formatnamepy def formatnamemystring s... blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting Business Reporting For Decision Making

Authors: Jacqueline Birt, Keryn Chalmers, Albie Brooks, Suzanne Byrne, Judy Oliver

4th Edition

978-0730302414, 0730302415

More Books

Students explore these related Programming questions

Question

Explain the term 'shareholder value'.

Answered: 3 weeks ago