short name in python

Solutions on MaxInterview for short name in python by the best coders in the world

showing results for - "short name in python"
Philippine
16 Feb 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]
Daniele
21 Apr 2017
1name = input("Please enter a name: ") #Short the name (V.S. Mathur)
2short = name.split()
3n = [x[0] for x in short[:-1]]
4print(*n, short[-1])
Bruno
09 Mar 2017
1def get_initials(fullname):
2  xs = (fullname)
3  name_list = xs.split()
4
5  initials = ""
6
7  for name in name_list:  # go through each name
8    initials += name[0].upper()  # append the initial
9
10  return initials