Answer:
The solution code is written in Python 3:
- input_char = input("Enter a character (except *): ")
- width = int(input("Enter a width: "))
- height = int(input("Enter a height: "))
-
- checkpoints = [0, height//2 - 1, height-1]
-
- for i in range (height):
-
- if i not in checkpoints:
- print(input_char)
- else:
- output = ""
- for j in range(width):
- output += input_char
-
- print(output)
Step-by-step explanation:
Firstly, we use input function to prompt use to input a character, width and height (Line 1 -3)
Next we create a checkpoints list to define the line number where the input character should be printed following the width number of times (Line 5).
Next we can create a for-loop to traverse through the number from 0 till height (exclusive of height itself) (Line 7)
If the current i is not found in the checkpoints list, the print function will only display one input character. Else it will print the input character for width number of times(Line 9 -14).
This will eventually result in an E shape.