0

I am just starting to learn Python and I am trying to make rectangle print out of a chosen symbol from the following test driver:

# prompt for input
base = input('Enter a positive integer for the base of the rectangle: ')
height = input('Enter a positive integer for the height of the rectangle: ')
character = input('Enter a character used to print the rectangle: ')
print()

# print the rectangle by calling the printRectangle function
print_rectangle(base, height, character)
print()

for a print_rectangle function I tried to make one that accepts 2 integers which are the base and height of a rectangle and a character which the rectangle shape has to be printed as parameters and to print the character in a rectangle shape with that provided base and height. The loop being there to iterate through the given number of times. When I try to input this the traceback says

TypeError: 'str' object cannot be interpreted as an integer

This relates to for _ in range(height): and print_rectangle(base, height, character) from the test driver. I am unsure of what I am doing wrong.

def print_rectangle(base: int, height: int, character):
    for _ in range(height):
        for _ in range(base):
            print(character, end=" ")
        print()
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Ron
  • 1

0 Answers0