I'm just a beginner in python. I was just writing some code to print table of any number and I surprisingly got different answers on python v2.7 & python v3.5! This occur only when I use string function, not when I use comma(,).
Asked
Active
Viewed 22 times
0
-
Please see [Why may I not upload images of code on SO when asking a question?](http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question) – PM 2Ring Aug 03 '17 at 04:46
-
1The difference in output is due to the difference between Python 2 `input` and Python3 `input`. – PM 2Ring Aug 03 '17 at 04:47
-
The `input` function is very different for python2 and python3, you should read the docs – Ofer Sadan Aug 03 '17 at 04:48
-
Refer the usage of `input` in Python2 and Python3 [here](https://stackoverflow.com/questions/4915361/whats-the-difference-between-raw-input-and-input-in-python3-x) – voidpro Aug 03 '17 at 04:51
-
1Possible duplicate of [What's the difference between raw\_input() and input() in python3.x?](https://stackoverflow.com/questions/4915361/whats-the-difference-between-raw-input-and-input-in-python3-x) – Steven Summers Aug 03 '17 at 04:53
-
See [Differences between input commands in Python 2.x and 3.x](https://stackoverflow.com/questions/19036188/differences-between-input-commands-in-python-2-x-and-3-x). BTW, you should concentrate on learning Python 3. Once you're comfortable with that, you can go back and learn about the differences between Python 3 & Python 2, if you really need to. Python 2 will reach its official End Of Life in 2020. – PM 2Ring Aug 03 '17 at 04:53
-
Thanks Everyone, now I got the real reason of this problem :) – khushwant soni Aug 03 '17 at 04:57
1 Answers
0
The difference is the type of 'n'. It is treated as an integer than you get the numeric operation '', in the other case it is treated as string with the string operation ''. Try out type(n) after you read it and you will see the difference.

funkr
- 101
- 3
-
I got to know that it was because of the input function! it have difference in Python 3.x & 2.x – khushwant soni Aug 03 '17 at 05:01