hello,
my name is bhargav and from last so many days i try to do %s or %d as study in the codecademy. it work online fine but if i type same code in my pc installed python (3.6) is show me error every time. it indicate me the % symbol side error. ex
a = ‘bhargav’
b = ‘dhaval’
print (“my name is %d and my brother name is %d.”,%(a,b))
i tried so many ways and trouble shoot problem but same happened in all even it also happened if i write code in ‘PYCHARM’ ide that also show me the same error.
ya bro i tell same thing if i try this code on online it works fine but if i try same code in my installed python 3.6 than it show me error. which version you are use ???
can you confirm (since i can’t see what you are doing) the code above doesn’t work? I know you said you tried many times, but can you explicitly confirm the code above doesn’t work?
well %d obviously doesn’t work, since it is for decimal numbers.
it seems they haven’t released 3.6 for linux, so i can’t run it yet.
$ hg clone https://hg.python.org/cpython
$ cd cpython
$ ./configure && make
<wait a few minutes while it builds>
$ ./python
Python 3.7.0a0 (default:897fe8fa14b5, Oct 14 2016, 18:43:26)
[GCC 6.2.1 20160830] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 'bhargav'
>>> b = 'dhaval'
>>> print ("my name is %s and my brother name is %s." %(a,b))
my name is bhargav and my brother name is dhaval.
Might want to sneak this in before configuring:
$ hg checkout v3.6.0b2
As seen above, that code does execute, and they wouldn’t be breaking backwards-compatibility like that anyhow, what runs in 3.5 also runs in 3.6. @bhargavna01 you simply didn’t run it correctly.
bro just check this three files. or tell me if anywhere i am wrong or make mistake. first file is from pycharm and other two are from python which are installed in my system.
And thanks for the solution.Uploading…Uploading…Uploading…
Contrary to what you said, you have not removed that comma. You’ve probably removed it on codecademy though, otherwise that would also not run because that comma isn’t allowed there, it doesn’t match python’s syntax
Side note: Remember that Python will highlight the first thing it does not expect, not the error itself. That would be just before the highlighted code. As others have pointed out, the comma is just before the error indicator.