Python – Space between two characters

Question:

def hashes(n):
    for x in range(0, n):
    print"#",

The above code produces the following result if n = 5:

# # # # #

Could anyone suggest a solution for making the characters have no space in between?

i.e

#####

(Python 2.7)

Asked By: Matt Walker

||

Answers:

def hashes(n):
    print "#" * n
Answered By: kindall

With print function

from __future__ import print_function
def hashes(n):
    for x in range(0, n):
        print("#", end='')
Answered By: P̲̳x͓L̳
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.