235k views
5 votes
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)​

User VonGohren
by
7.9k points

1 Answer

0 votes

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}')

User Ravi Jiyani
by
8.2k points

Related questions

1 answer
1 vote
160k views
asked Jul 8, 2024 135k views
Patrick Magee asked Jul 8, 2024
by Patrick Magee
7.4k points
1 answer
1 vote
135k views
asked Nov 4, 2024 20.9k views
Demokritos asked Nov 4, 2024
by Demokritos
8.5k points
1 answer
4 votes
20.9k views