Python Help
Go to solution
Solved by Linus_torvalds,
Do you know how I would implement that in this case???
here it works
def border_msg(msg): split_msg = None longest = 0 border = None message = None mylist = [] split_msg = msg.split('\n') for i in split_msg: mylist.append(i) longest = len(max(mylist, key=len)) border = '+%s+\n' %('-'*(longest + 2)) message = border for i in split_msg: message += '| %s |\n' % i.center(longest, ' ') message += border return message print(border_msg('hello there\nmy name is nick'))
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now