(Solved):Using Python, write a method center that takes a string st and a field size width and returns a centered version of the string within the given field. Add spaces to each side of st to center it. No… View Answer…

 

Question

Using Python, write a method center that takes a string st and a field size width and returns a centered version of the string within the given field. Add spaces to each side of st to center it. Note:

You can find the number of characters in a string with len(st).

st is guaranteed to contain an even number of characters

width is also guaranteed to be even.

width may be less than len(st).

Scroll to top