Question

Write a function first_last(name), that given a name in the form of 'Chapman, Graham Arthur' will...

Write a function first_last(name), that given a name in the form of 'Chapman, Graham Arthur' will return it to the form 'Graham Arthur Chapman'. (string split method)

Need it in python 3 code

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def first_last(name):
    words = name.split()
    return words[1] + ' ' + words[2] + ' ' + words[0][:-1]


print(first_last('Chapman, Graham Arthur'))

Add a comment
Know the answer?
Add Answer to:
Write a function first_last(name), that given a name in the form of 'Chapman, Graham Arthur' will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In python Write a function called removeExtensión that is given the name of a file as...

    In python Write a function called removeExtensión that is given the name of a file as a string and returns the same string without the extension (the last "" and any following characters); if the given string has no extension, return the given string without changing it. For example, removeExtension"Chapter 3.9.txt") should return "Chapter 3.9" while removeExtension("Hello") should return "Hello"

  • Language: Python Function name : findwaldo Parameters : string Returns: int Description: Write a recursive function...

    Language: Python Function name : findwaldo Parameters : string Returns: int Description: Write a recursive function that takes in a string containing some combination of letters, numbers, and spaces, and return the starting index of the first instance of “waldo” contained in that string. If the string does not contain “waldo”, return -1. This function IS case sensitive, so “waldo” is not the same as “WALDO”. Code using string functions such as .index() and .find() that oversimplify the problem will...

  • C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the r...

    C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the required information. Your function should return the number of student entries read from the file. Empty lines do not count as entries, and should be ignored. If the input file cannot be opened, return -1 and do not print anything.     Your function should be named...

  • Using swift 4.0, Write a function (not method) named findName which returns a given name (passed...

    Using swift 4.0, Write a function (not method) named findName which returns a given name (passed as a parameter) if it is in the string array passed as a parameter, otherwise return nil Demonstrate calling the function findName. Using swift 4.0

  • C++ Write a recursive function that reverses the given input string. No loops allowed, only use...

    C++ Write a recursive function that reverses the given input string. No loops allowed, only use recursive functions. Do not add more or change the parameters to the original function. Do not change the main program. #include <iostream> #include <string> using namespace std; //Write a recursive function 'void reverse(string &str)' that reverses the given input string. void reverse(string &str) { /*Code needed*/ } int main() {    string name = "sherry";    reverse(name);    cout << name << endl; //should...

  • In Python 3, write a function that will take an integer which represents a time given...

    In Python 3, write a function that will take an integer which represents a time given in military time (0 – 2359) and return a string that represents the time in a 12-hour format. If an invalid time is given, the function must return the string “Invalid time”. Examples 1200 will return the string “12:00 PM” 2240 will return the string “10:40 PM” 0600 will return the string “06:00 AM” 2400 will return the string “Invalid time” 1160 will return...

  • python Implement function get_contact(contacts, name) that returns a string. The contacts and the name parameter are...

    python Implement function get_contact(contacts, name) that returns a string. The contacts and the name parameter are both type string. This function checks for the name string in the contacts string and returns that person's contact information. If the person is not found, the function returns, "name not in contact". Assume input is always valid. Assume the same name is not repeated in contacts. [You may use split(), range(), len() ONLY and no other built-in function or method] Examples: contacts =...

  • Task 1: Write a Python program that takes as input from the user the name of a file containing po...

    python code: Task 1: Write a Python program that takes as input from the user the name of a file containing postcode/location information. Each line in the file consists of the postcode followed by a tab followed by a comma-separated list of locations that have that postcode. For example, the file Small.txt contains: 3015 Newport,South Kingsville,Spotswood 3016 Williamstown 3018 Altona,Seaholme 3019 3021 Albanvale,Kealba,Kings Park,St Albans Braybrook, Robinson Your program should create a list of postcode/location pairs with each pair stored...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a function...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a function named capital_letter that accepts a string as an argument and checks if each word in the string begins with a capital letter. If so, the function will return true, otherwise, return false. Please see the outcome below: Outcome number 1: Enter a string: Python Is Really Fun! True Sample run number 2: Enter a string: i Love Python False Note: Try to keep this...

  • Below is the PHP function to sanitize incoming values from web pages. Write code to call...

    Below is the PHP function to sanitize incoming values from web pages. Write code to call this function in the if(isset(x)) code block. Example is given to you below. function mysql_fix_string($conn, $string){ if(get_magic_quotes_gpc(i) $string = stripslashes($string); } return $conn->real_escape_string($string); Il Il Il Il Il II II Il 11 11 = 11 11 = 11 global $conn; if(isset($_POST['name'])) { $name = $_POST['name']; al [Select] he function $name = mysql_fix_string($string); $name = mysql_fix_string($conn, $string); $name = mysql_fix_string($conn, $name); $name = get_magic_quotes_gpc($name);

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT