initials of a name in python

Solutions on MaxInterview for initials of a name in python by the best coders in the world

showing results for - "initials of a name in python"
Julia
27 Jan 2020
1raw_name = input("\nEnter Full Name : ") 
2name = raw_name.strip()
3bname  = name.split(' ')
4lenofstr = len(bname)
5fname = bname[0]
6leofstrstr = str(lenofstr)
7vlname = int(lenofstr) - 1
8lname = bname[int(vlname)]
9print("\nHi,"+bname[0])
10print("\nHi,",end="")
11for i in bname:
12    if i == lname:
13        break
14    print(i[0].upper()+".",end="")
15print(lname+"\n")
16
17##This is the second method with more compact code
18raw_name = input("\nEnter Full Name : ").strip().split(' ')
19lname = raw_name[int(int(len(raw_name)) - 1)]
20[print(i[0].upper()+".",end="") if i != lname else print(lname+"\n") for i in raw_name]