Oct-19-2017, 04:59 PM
Hello, I am having difficulty with a homework assignment that asks me to code a print statement where the string input gets surrounded by asterisks. The question itself is... "Write a Python function banner that takes a string (say, str) and returns
a string that “surrounds” str with asterisks, as illustrated below:
>>> banner ("hello")
’*********\n* hello *\n*********\n’
>>> print (banner ("hello"))
*********
* hello *
*********
Right now, the code I have is:
def line(width,ch='*'):
return(width*ch+"\n")
I am asked to only use simple techniques that don't include iterators or other advanced features or libraries of Python. Thank you for any help you can provide!
a string that “surrounds” str with asterisks, as illustrated below:
>>> banner ("hello")
’*********\n* hello *\n*********\n’
>>> print (banner ("hello"))
*********
* hello *
*********
Right now, the code I have is:
def line(width,ch='*'):
return(width*ch+"\n")
I am asked to only use simple techniques that don't include iterators or other advanced features or libraries of Python. Thank you for any help you can provide!