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)
Answers:
def hashes(n):
print "#" * n
With print function
from __future__ import print_function
def hashes(n):
for x in range(0, n):
print("#", end='')
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)
def hashes(n):
print "#" * n
With print function
from __future__ import print_function
def hashes(n):
for x in range(0, n):
print("#", end='')