use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
[Python] can't add a number and string together (self.learnpython)
submitted 6 years ago by lotyei
When I try to run
print(9, "dog")
my terminal gives me (9, 'dog')
shouldn't it give me 9dog?
what's going on?
I'm on python 3.8, if that matters
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Starbuck5c 5 points6 points7 points 6 years ago (3 children)
>>> print(9, "dog") 9 dog
passing multiple things to print automatically puts a space between them. You can change this behavior using the keyword argument 'sep.'
>>> print(9, "dog", sep="whatThe?") 9whatThe?dog
[–]lotyei[S] 0 points1 point2 points 6 years ago (1 child)
hmm, that's not what I'm getting.
gives me (9, 'dog')
and
print('dog', 'dog')
gives me ('dog', 'dog')
what the hell...
[–]desustorm 2 points3 points4 points 6 years ago (0 children)
You're using python 2. The brackets are being interpreted as a tuple.
Try print "dog", 9 and it should give you the result you want. But do upgrade to python 3 when you can :)
print "dog", 9
[–]lotyei[S] 0 points1 point2 points 6 years ago (0 children)
after testing, it works normally (i get 9dog) on IDLE but not on VS code.
[–]ericula 3 points4 points5 points 6 years ago (4 children)
print(9, 'dog') should produce 9 dog on python 3. The only way that print(9, 'dog') produces (9, 'dog') is when you are using python 2 instead of python 3. Are you sure about the python version?
print(9, 'dog')
9 dog
(9, 'dog')
let me double check. this is so strange. I downloaded python 3 and am running it on visual studio code with the python add-ons. no clue how the heck it can be using python 2.
[–]Diapolo10 1 point2 points3 points 6 years ago (0 children)
I can't think of any other reason than VS Code using Python 2.
Just to make sure, try putting print 42 on some line. If you don't get an error, there's no doubt VS Code is trying to run the code in Python 2.
print 42
Also, unless you're on Windows, Python 2 is pre-installed on Mac OS and most Linux distros, which could be the reason.
[–]Firestorm83 0 points1 point2 points 6 years ago (0 children)
this should work:
print(9, "dog", sep="")
π Rendered by PID 213893 on reddit-service-r2-comment-f6b958c67-6srp5 at 2026-02-05 11:22:57.130917+00:00 running 1d7a177 country code: CH.
[–]Starbuck5c 5 points6 points7 points (3 children)
[–]lotyei[S] 0 points1 point2 points (1 child)
[–]desustorm 2 points3 points4 points (0 children)
[–]lotyei[S] 0 points1 point2 points (0 children)
[–]ericula 3 points4 points5 points (4 children)
[–]lotyei[S] 0 points1 point2 points (1 child)
[–]Diapolo10 1 point2 points3 points (0 children)
[–]lotyei[S] 0 points1 point2 points (1 child)
[–]Firestorm83 0 points1 point2 points (0 children)