Python Forum
syntax error near unexpected token
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
syntax error near unexpected token
#1
Hello! ultra noobie with all things programming and I am currently registered in an online python course. During the tutorials I got stuck when I was prompted to enter a line:

name="BRADY H".lower()
This happens in only Visual Studio Code

It is supposed to be an example of the various python functions you can use but when I use this or .upper() or .replace() or any of the other tutorial functions I keep getting the error

Error:
bash:syntax error near unexpected token `('
Also I have tried:

my_book="My favorite book is 'Tod Sawyer',".replace('Tod', 'Tom')
print(my_book)
but get the same error...
This happens in both the editor (Visual Studio Code) and the shell/terminal on my computer. Please help as I am eager to learn but feel I can't even get started!
Reply
#2
Doesn't look like there is anything wrong with the code posted.
Reply
#3
Could it have to do with the PATH when python was installed then? I'm sorry I wish I could give you more information but this is all I have to work with and why I am here on the forums. Also thank you for reformatting my question for me, my apologies.

Also when the functions are typed out in Visual studio code they do not change color to cyan, as illustrated in most tutorials. I don't think this would be the issue as the shell has no problem with it.
Reply
#4
Your error starts with 'bash,' so you seem to be running the code in the bash shell rather than in Python. If it only happens in Visual Studio, I would guess you don't have Visual Studio set up correctly to run Python code. However, I am not familiar with Visual Studio, and would have no idea how to fix that.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
Make sure you have the python extension installed
Reply
#6
Thank you this information is very helpful. Hopefully it will give me enough to troubleshoot the issue through google. I have also verified that the python extension within VSC is installed and active
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Syntax error for "root = Tk()" dlwaddel 15 1,012 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 334 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 1,451 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,136 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  syntax error question - string mgallotti 5 1,251 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,194 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 847 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  Python-for-Android:p4a: syntax error in main.py while compiling apk jttolleson 2 1,777 Sep-17-2022, 04:09 AM
Last Post: jttolleson
  Mysql Syntax error in pymysql ilknurg 4 2,290 May-18-2022, 06:50 AM
Last Post: ibreeden
  Refresh token for Wyze SDK duckredbeard 0 1,077 May-16-2022, 04:33 AM
Last Post: duckredbeard

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020