if person is male their username is the last 3 letters of their surname and the first 2 letters of their first name if a person is female their username is the first 3 letters of their first name and the last 2 letters of their last name. write an algorithm to output a username (Could you answer in Python pls)​

Respuesta :

gender = input("What's your gender? (`male` or `female`): ")

firstname = input("What's your firstname?: ")

surname = input("What's your surname?: ")

username = ""

if gender == "male":

   username += surname[-3:]

   username += firstname[0:2]

elif gender == "female":

   username += firstname[0:3]

   username += surname[-2:]

print(f'Your username is {username}')