Write a script that creates users based on following names U

Write a script that creates users based on following names: Username is the first letter of first name and first 7 letters of last name: total 8 letters Example: David Khan rightarrow dkhan Wayne Rothwell rightarrow wrothwel If you see the duplicate names, John Doe righttarrow jdoe Jane Doe rightarrow jadoe john Doe rightarrow jodoe names4accounting. list Wayne Rothwell Fatima Scoggin Isabell Asaro Shondra Rosinski Alix Nembhard Marjory Case Tamra Buckles Chara Ruffo Davida Olmos Madlyn Cost Eliza Kober

Solution

def username(lst, name):
    name = name.split(\" \")
    name[0] = name[0].lower()
    name[1] = name[1].lower()
    uname = name[0][0] + name[1][0:7]
    if uname in lst:
        uname = name[0][0:2] + name[1][0:7]
    return uname

names4accounting = [\"Wayne Rothwell\", \"Fatima Scoggin\", \"Isabell Asaro\", \"Shondra Rosinski\", \"Alix Nembhard\", \"Marjory Case\", \"Tamra Buckles\", \"Chara Ruffo\", \"Davida Olmos\", \"Madlyn Cost\", \"Eliza Kober\"]
uname_list = []
for name in names4accounting:
    uname_list.append(username(uname_list, name))
print uname_list

 Write a script that creates users based on following names: Username is the first letter of first name and first 7 letters of last name: total 8 letters Exampl

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site