Stray new line after user input

Whilst attempting CS50’s PSET6, I was trying to create a double-half pyramid of a size specified by the user.

The pyramid is fine but there’s a random new line after the user input and before the pyramid starts. How can I fix it? Any help is appreciated 😀

The code is as follows

def main():     hashHeight = height()     create(hashHeight)      # get height def height():     h = int(input("Height: "))     if h >= 1 and h <= 8:         return h     else:         height()  #print hash def create(x):     for i in range(x + 1):         print(" " * (x - i) + "#" * i + "  " + "#" * i)  main() 
Add Comment
1 Answer(s)
def main():     hashHeight = height()     create(hashHeight)      # get height def height():     h = int(input("Height: "))     if h >= 1 and h <= 8:         return h     else:         height()  #print hash def create(x):     for i in range(1, x + 1):         print(" " * (x - i) + "#" * i + "  " + "#" * i)  main() 
Answered on July 16, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.