How would i properly Integrate End="" parameter within python function [closed]

  function, methods, parameters, python

I have been tasked to create a parallelogram using the required function below

def repeatChar(numRepeats, outputChar):
    '''
    output the outputChar numRepeats times on the same line
    '''
    for colNo in range(numRepeats):
        print(outputChar, end='')  # print outputChar and stay on the same line (don't go to next line)  

Working Solution but does not make proper use of the End parameter

def repeatChar(numRepeats, outputChar):
        output = ""
        for colNo in range(numRepeats):
            output += outputChar
        return output
   
    
    def main():
        print("This program will output a prallelogram.")
        side = int(input("How long do you want wach side to be? "))
        char = input("Please enter the character you want it to be made of: ")
        output = ""
        
        # loop to output the top triangle
        for topTriangle in range(1, side + 1):
            output += repeatChar(topTriangle, char) + "n"
    
        # loop to output the bottom triangle
        for btmTriangle in range(1, side + 1):
            output += repeatChar(btmTriangle, " ") + repeatChar((side - btmTriangle), char) + "n"
        print(output)
    
    
    main()

Source: Python Questions

LEAVE A COMMENT