In: Computer Science
Email username generator Write an application that asks the user to enter first name and last name. Generate the username from the first five letters of the last name, followed by the first two letters of the first name. Use the .toLowerCase() method to insure all strings are lower case. String aString = “Abcd” aString.toLowerCase(); aString = abcd Use aString.substring(start position, end position + 1) aString.substring(0, 3) yields the first 3 letters of a string If the last name is no more than five letters, use the entire name. If it is more than five letters, use the first 5 letters Print the email username you generated with @myCollege.edu appended
#taking user input
f_name=input("Enter first name")
l_name=input("Enter last name")
#initializing result variable a
a=""
#checking if last name is greater than 5 alphabets and converting it to lower case
if len(l_name)>5:
a+=l_name[:5].lower()
else:
a+=l_name.lower()
#checking if first name is greater than 2 alphabets and converting it to lower case
if len(f_name)>2:
a+=f_name[:2].lower()
else:
a+=f_name.lower()
#final output
print("The username is "+a+("@myCollege.edu"))
Sample Output: