+ 5
[CHALLENGE] Formate the names correctly
write a program to do the following: for ex: the inputed person's name is "steve jobs", then we have to capitalize the first letters of the first name , surnames as well as the middle names. (other should be small) we have to keep the full surname, and only first letters of the first name and middle name with a "."(dot). few test cases: 1. steve jobs = S. Jobs 2. avay kumar nath= A. K. Nath 3. benidict cuMBerBATCH= B. Cumberbatch #display the output as well as change the original string too.
11 Antworten
+ 3
C# has special function for that:
CultureInfo.CurrentCulture.TextInfo.ToTitleCase(string)
Then it just needs to take first letters.
Full code: https://code.sololearn.com/cZ35CmjDRE36/#cs
+ 12
JavaScript:
var a = prompt("").trim().split(" ");
alert(a.slice(0, a.length - 1).reduce(function(a, b) { return a + b.charAt(0).toUpperCase() + ". "; }, "") + a[a.length - 1]);
+ 11
Thanks for the challenge.
Here's my try :
https://code.sololearn.com/c8piyQCxKrhl/?ref=app
+ 7
python
i = input().title().split()
print(*[i[j][0]+'.' for j in range(len(i)-1)], i[-1])
+ 5
@Sudipta check properly
+ 2
@kazi your code is fine.
but it is not satisfying case 3
other letters also should be converted to small letter. except the first letters.
+ 2
I coded a thing! (Not sure how to post, either, ohno...)
https://code.sololearn.com/cStl2P64Frp1/?ref=app
+ 1
@Krishna Teja Yeluripati
Your code will not be working because the code doesn't process extra spaces and doesn't capitalize the last name.
Just FYI ;)
+ 1
0
@kazi its correct now