My Python code:
mapArray = [["#","#","#"],["#","#","#"],["#","#","#"]]
for row in mapArray:
for cell in row:
print cell,
print
print
prints this:
# # #
# # #
# # #
why not this:
###
###
###
Thanks much!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
My preferred solution when I want Python to only print what I tell it to without inserting newlines or spaces is to use
sys.stdout:The print statement documentation states,
"A space is written before each object is (converted and) written, unless the output system believes it is positioned at the beginning of a line."This is whysys.stdoutis the preferred solution here and is the reason why you’re seeing spaces in your output.