Epython Lab
#CODE_CHALLENGE_2 #FUNCTION #LIST_SLIC #STRING 1. Commercial bank of Ethiopia realized that their policy of using the first five letters of an employee’s last name as a user name isn’t ideal when they have multiple employees with the same last name. Write…
Best solution is done by Sami(@Smlazne). Thanks for your contribution.
#AlternativeSolution
first_name = "Asibeh"
last_name ="Tenager"
def account_generator(first_name, last_name):
new_account = first_name[:3] + last_name[:3]
return new_account
# another function password generator
def password_generator(first_name, last_name):
new_pass = first_name[len(first_name)-3:] + last_name[len(last_name)-3:]
return new_pass
# call and print the result
# call and test the function
new_account = account_generator(first_name, last_name)
print(new_account)
temp_password = password_generator(first_name, last_name)
print(temp_password)
#If we wanted to find the last three letters of a string, we could use len:
#AlternativeSolution
first_name = "Asibeh"
last_name ="Tenager"
def account_generator(first_name, last_name):
new_account = first_name[:3] + last_name[:3]
return new_account
# another function password generator
def password_generator(first_name, last_name):
new_pass = first_name[len(first_name)-3:] + last_name[len(last_name)-3:]
return new_pass
# call and print the result
# call and test the function
new_account = account_generator(first_name, last_name)
print(new_account)
temp_password = password_generator(first_name, last_name)
print(temp_password)
#If we wanted to find the last three letters of a string, we could use len: