Question regarding printing a string and number together

0 Farhana Chowdhury Tondra · March 23, 2015
I have a question regarding the session 10. In the tutorial mentor shows that if we print number and string at the same time in a print statement then we just separate them with a ','comma. But I can see the result comes in my editor pycharm is different. . 

Input : print(10, "Hi")
Output: C:\Python25\python.exe D:/Python/
(10, 'Hi')

Process finished with exit code 0

why the output is coming as a single string??

Post a Reply


Oldest  Newest  Rating
0 alex constantin · March 24, 2015
Try doing:

print (str(10) + ' Hi!')

The plus sign in strings concatenates them raw, meaning no spaces, so you add a space before ' Hi!'
That should output as a single string.
  • 1



This section is all about snakes! Just kidding.

Bucky Roberts Administrator