In: Computer Science
In Python, accept shoter names and pad them with X’s to fill out the 3 characters needed.
So for example
>>> print(user_name("Bo", "Li"))
BoXLiX
>>> )
#define function
def user_name(str1, str2):
#checks if length of str1 is less than 3
if(len(str1) < 3):
#if length is less than 3 then append X until length of str1 becomes 3
for i in range(len(str1),3):
str1 = str1 + 'X'
#checks if length of str2 is less than 3
if(len(str2)<3):
#if length is less than 3 then append X until length of str2 becomes 3
for i in range(len(str2),3):
str2 = str2 + 'X'
#return both string
return str1+str2
#call user_name function and print the result
print(user_name("Bo","Li"))