Write a Python program that asks the user to enter full name in the following format:
LastName, FirstName MiddleName
(for Example: "Hun, Attila The”).
The input will have a single space after the comma and only a single space between the first name and the middle name. Use string methods and operators in Python to convert this to a new string having the form:
FirstName MiddleInitial Period LastName (for example: "Attila T. Hun") and output it.
Be sure to test it with more than one input and not just "Hun, Attila The".
Sample Output 1:
Enter name in [LastName, FirstName MiddleName] format >Newton, Sir Isaac
The new name is : Sir I. Newton
Sample Output 2:
Enter name in [LastName, FirstName MiddleName] format >Hun, Attila The
The new name is : Attila T. Hun
è½å¦ç¿»è¯ä¸å¢ï¼åå.............
#python 3.3 ä¸ç script没çæããã
追çä½ ç¨ä»ä¹çæ¬çpythonå¢ï¼
能具体点么
追答lName = raw_input('Please enter your last name:')
fName = raw_input('Please enter your first name:')
mName = raw_input('Please enter your middle name:')
allName = "%s, %s %s"%(lName, fName, mName);
print allName
allName2 = fName + " " + mName[0:1] + ". " + lName#transform
print allName2
#Enter name in [LastName, FirstName MiddleName] format >Newton, Sir Isaac
#The new name is : Sir I. Newton
output是这样。。。
上面的代码不就是Sampl1, Sample2所要求的吗。
自己加个提示信息就可以了---
lName = raw_input('Please enter your last name:')题目是要求 Lastname, middle name和first name 一起输入,然后直接出结果。。
追答哦 没细看。
print('Please enter your last name')