Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 4: Simple ASCII Art For this next exercise, you'll need to complete the function gen_pattern , which, when called with a string of length
Exercise 4: Simple ASCII Art For this next exercise, you'll need to complete the function gen_pattern , which, when called with a string of length > 1, will print an ASCII art pattern of concentric diamonds using those characters. The following are examples of patterns printed by the function (note the newline at the end of the last line!): > gen_pattern('x') > gen_pattern('XY') ..Y.. Y.X.Y ..Y.. > gen_pattern('WXYZ') .Z...... .Z.Y.z.... ..2.Y.X.Y.Z.. Z.Y.X.W.X.Y.Z ..2.Y.X.Y.Z.. ...Z.Y.Z.... .Z.. You ought to find the string join and center methods helpful in your implementation. They are demonstrated here: '*'.join('abcde') 'a*b*c*d*e' > 'hello'.center(11,'*') ****hello***' Complete the gen_pattern function, below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started