I am still preparing the material for the next python project and in order to keep this website alive, I will continue to solve easy questions from
In this next example we will create a python method which will receive a name of a person, then it will only take the first letter from the first name, last name or even the middle name and turns that letter into the capital letter if that character is indeed a lower case letter. All the characters will be concatenated with a ‘.’ before
def abbrevName(name): name_list = name.split(' ') s = '' for name in name_list: s+=name[0:1].upper() + '.' return s[0:len(s)-1]
So if we enter below name into that method.
print(abbrevName("Jason stock Bond"))
Then this program will return “J.S.B”
If you have a better solution than mine then let keep it up by leaving your solution in the comment box below this post.