Re: [Tutor] Python trouble (Nathan Clark)
Hi, the problem is in the line that says: terms = int(input("How many terms of the fibonnaci sequence would you like?") is missing a closing ')' take a look: terms = int(input("How many terms of the fibonnaci sequence would you like?")) Hope you help. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python trouble
On Tue, Dec 29, 2015 at 11:52 AM, Nathan Clark <26110...@gmail.com> wrote: > This is a fibonnaci sequence generator, the colon causes a syntax error > > > #set variables > num_1 = 1 > num_2 = 2 > count = 0 > terms = int(input("How many terms of the fibonnaci sequence would you > like?") > > > #function > while terms != count : > num_3 =num_1+num_2 > print (num_3) > num_1=num_2 > num_2 = num_3 > this can be simplified to num_1, num_2 = num_2, num_3 > count=count+1 > else: > print ("finished") > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Joel Goldstick http://joelgoldstick.com/stats/birthdays ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python trouble
On 29/12/15 16:52, Nathan Clark wrote: > This is a fibonnaci sequence generator, the colon causes a syntax error Please always post the full error text. It contains much useful information. > terms = int(input("How many terms of the fibonnaci sequence would you > like?") Count the parentheses... > while terms != count : The syntax error is marked against this line because is where Python first finds something it can't recognise but the actual error is further back. That's why, with syntax errors, you should always check a line or two before the marked error point. In particular always check for mis-matched quotes, brackets/parens or indentation errors - these are the most common mistakes. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Trouble, Please Help!
On 25/07/13 00:23, Jonathan Hong wrote: because of my lack of computer knowledge. When I do put in python helloworld.py into the command prompt line, the computer gives me a response of: "python: can't open file 'hello.py': [Errno 2] No such file You need to supply the full path to the file (or be in the same directory as the file) when you try to run it. Mostly on Windows you can run scripts from Windows explorer but for simple scripts (like hello world) the window appears and then dissappears too quickly to see it. You can most easily get around that by putting one of: raw_input("Hit Enter to quit") # for Python v2 input("Hit Enter to quit") # for Python v3 as the last line in your script. You might find that technique easier than using the CMD window. But the CMD window is better when things go wrong - it lets you see any error messages,... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Trouble, Please Help!
Hi, On 25 July 2013 00:23, Jonathan Hong wrote: > Hello, > > I am currently working with the Python programming language and had a very > basic question regarding the start up of Python. For some reason, when I > open up the Command Prompt in my Windows 7 computer, I am unable to access > python files. > I'd like to add the following suggestion to the link Antonio's already sent you: http://www.voidspace.org.uk/python/articles/command_line.shtml Regards, Walter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python trouble
"Steven D'Aprano" wrote Ok let me try to be more clear. I am trying to write code in the IDLE Python GUI of python 2.7. start a command that goes over two or more lines, the prompt will change to three dots ... Sadly in IDLE it won't do this (I hate that feature of IDLE!) but it will indent the cursor for you, padding the line with tabs. Please COPY and PASTE an example of the system error. Do not retype it, especially not from memory, but actually copy and paste the complete error, including the line it claims is invalid, and paste it into a reply. Like this: Again IDLE makes this difficult if you are running from a New Window because it presents the error in a pop up dialog, while highlighting the "faulty line" in the edit window, but please do try to send the actual error text. Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python trouble
Alex Butler wrote: Ok let me try to be more clear. I am trying to write code in the IDLE Python GUI of python 2.7. When I open the new python shell, there is a written header as well as the three >s on the left side. I now those are used as indents and I do not type them in. However, whenever I write any type of code and either attempt to run or click alt + x to check module, it says "there is an error in your program: invalid syntax." Then when it goes back to the page to highlight the syntax error the second > is highlighted in color as it is the problem. Before I deleted the header from this program, it would highlight the 7 after the 2. In the header. The >>> is called the prompt. It is not part of the code, it is just there to prompt you that the interpreter is waiting for you. If you start a command that goes over two or more lines, the prompt will change to three dots ... to remind you that you haven't finished writing the command yet. Please COPY and PASTE an example of the system error. Do not retype it, especially not from memory, but actually copy and paste the complete error, including the line it claims is invalid, and paste it into a reply. Like this: >>> x = 1 >>> y = 2 >>> if x=y: File "", line 1 if x=y: ^ SyntaxError: invalid syntax Thank you. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python trouble
On 22-Apr-11 11:52, Alex Butler wrote: Ok let me try to be more clear. I am trying to write code in the IDLE Python GUI of python 2.7. When I open the new python shell, there is a written header as well as the three >s on the left side. I now those are used as indents and I do not type them in. However, whenever I write any type of code and either attempt to run or click alt + x to check module, it says “there is an error in your program: invalid syntax.” Then when it goes back to the page to highlight the syntax error the second > is highlighted in color as it is the problem. Before I deleted the header from this program, it would highlight the 7 after the 2. In the header. Okay, that's pretty much what you said last time. What is the actual code you're trying to run? If it's really complaining about >>> being a syntax error, it sounds like you're confused about where you are in the tool or extra text is getting pasted. If you open a new source window (file->new) (not a "shell" window), and type some python code, that window won't have a header line or >>> prompts at all, just your code. So... start IDLE select File->New; new untitled window pops up type a python program, maybe this: print "hello" hit alt-X (although personally, I'd hit F5 instead). It should prompt you for a file to save your new program into, then run it back in the other window (the shell) that has the >>>s in it. How, exactly, does what I just described differ from what happened to you? -- Steve Willoughby / st...@alchemy.com "A ship in harbor is safe, but that is not what ships are built for." PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor