119k views
21 votes
Write a program code to accept the names of 3 users and generate a user name as shown in the example. Accept the name of 3 user in the format – Firstname Last name (eg. Anan Gupta). Select the first 3 characters from the first name, add # and then add last 3 characters of the last name. Display the newly generated user name along with the names that were input.

User Miguelito
by
4.4k points

1 Answer

11 votes

Answer:

Step-by-step explanation:

The following code is written in Python and is a function that loops three times asking for the last name and first name. Then it uses this information to create a username. Finally, each of the names and usernames is printed on the screen.

def userName():

for x in range(3):

last_name = input("What is your last name: ")

first_name = input("What is your first name: ")

username = first_name[:3] + "#" + last_name[-3:]

print(last_name + ", " + first_name)

print(username)

User Affe
by
4.7k points