![]() |
Just starting out, allready stuck.. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Just starting out, allready stuck.. (/thread-7353.html) Pages:
1
2
|
Just starting out, allready stuck.. - Sandman - Jan-05-2018 Hi. I'm not really a student, but i sort of made it a new year's resolution to learn how to code. This seemed like the appropriate place to ask my question. I apologize if it's not. I started reading a book on learning python and i'm allready stuck on one of the first exercises :/ So the task involves the change direcory command. I'm supposed to write these commands in a terminal: C:\> cd Desktop\python_work C:\Desktop\python_work> dir hello_world.py C:\Desktop\python_work> python hello_world.py After the first line i always get this message: SyntaxError: unexpected character after line continuation character To explain: i had to write a simple line of code so that the message 'Hello Python world!' would be printed and save it in Geany as 'hello_world.py'. The commands above should be written in the terminal to run this code. I hope i've given enough information to help me clarify what's amiss here. I'm serious about learning to code and it's kinda frustrating to be stuck right at te start :s Python version: Python 3.6.4 OS: Windows 7 RE: Just starting out, allready stuck.. - mpd - Jan-06-2018 You need to post your code so we can see what is going on. Be sure to format it (with the little python button in the toolbar) RE: Just starting out, allready stuck.. - Sandman - Jan-06-2018 there's really not much to the code, it's a simple print command print("Hello Python world!")it's trying to run it from the terminal with the instructions from the book where things go wrong RE: Just starting out, allready stuck.. - squenson - Jan-06-2018 We need to check which version of python you are running. Just type python and let us know what you get as a version (to exit the shell, type exit() ).(I know that you mentioned the python version in your first post, it is just to double-check it...) Also, verify that there are no "invisible" characters in your hello_word.py file after the last parenthesis. Position your cursor after it and press the Delete key many times to be sure. RE: Just starting out, allready stuck.. - Gribouillis - Jan-06-2018 Such things may happen if you copy and paste code from certain files such as pdf files to your editor. These files contain invisible characters that produce invalid python code (this is not a python specific issue). You can delete the whole file and type it by hand. In fact there is a well known online tutorial named "Learn python the hard way". Its main paradigm is to type every single character of every program in the tutorial! No copy and paste is allowed. RE: Just starting out, allready stuck.. - sparkz_alot - Jan-06-2018 In addition to the already mentioned advice, make sure, when you are writing your code that you do NOT use a 'formatting' text editor such as MS Write or MS Word. These editors also insert 'hidden' formatting characters. Instead, use a plain text editor like Notepad or a better option is the free Notepad++ (with the Python plugin). In addition, do not mix tabs and spaces, in Python always use 4 spaces for indentation. RE: Just starting out, allready stuck.. - Sandman - Jan-06-2018 (Jan-06-2018, 11:12 AM)squenson Wrote: We need to check which version of python you are running. Just typePython version 3.6.4 (v3.6.4:d48eceb). I thought your advice on deleting possible white spaces would work, but alas :( (Jan-06-2018, 12:15 PM)Gribouillis Wrote: Such things may happen if you copy and paste code from certain files such as pdf files to your editor. These files contain invisible characters that produce invalid python code (this is not a python specific issue).i typed it myself, didn't copy/paste. i even tried to copy/paste before, but it didn't do anything :D (Jan-06-2018, 01:30 PM)sparkz_alot Wrote: In addition to the already mentioned advice, make sure, when you are writing your code that you do NOT use a 'formatting' text editor such as MS Write or MS Word. These editors also insert 'hidden' formatting characters. Instead, use a plain text editor like Notepad or a better option is the free Notepad++ (with the Python plugin). In addition, do not mix tabs and spaces, in Python always use 4 spaces for indentation.nope. i used Geany. supposedly this is a helpful tool to write your code in. i'll add the message i'm getting in python tags >>> C:\> cd Desktop\python_work File "<stdin>", line 1 C:\> cd Desktop\python_work ^ SyntaxError: unexpected character after line continuation characterdoes the little '^' under the last k mean anything..? RE: Just starting out, allready stuck.. - squenson - Jan-06-2018 You must type the cd Desktop\python_work statement (don't type C:\, this is the prompt) and the python hello_world.py command at the prompt level. You don't need to be inside the python shell.
RE: Just starting out, allready stuck.. - Sandman - Jan-06-2018 (Jan-06-2018, 07:10 PM)squenson Wrote: ...command at the prompt level. You don't need to be inside the python shell.i don't understand what this means RE: Just starting out, allready stuck.. - Gribouillis - Jan-06-2018 It won't work in the python shell. The cd command works in a terminal/console. But Geany has probably a keyboard shortcut to run the program.
|