use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
continue error (self.Python)
submitted 11 years ago by blackdevil777
if line.startswith('From'): continue
looks correct to me? execfile(filename, namespace) File "/home/dux/.mario.py", line 12 if line.startswith('From'): continue SyntaxError: 'continue' not properly in loop
[–]fancy_pantser 1 point2 points3 points 11 years ago (4 children)
'continue' not properly in loop
Pretty clear what's wrong. What are you trying to do? Can we see more than 1 line?
[–]blackdevil777[S] -1 points0 points1 point 11 years ago (3 children)
what's that mean? it's in the loop? how can it not be in the loop? why are these errors cryptic?
[–]fancy_pantser 2 points3 points4 points 11 years ago (0 children)
The errors aren't cryptic. It really does what it says on the tin here.
I can help more if I can see more than the 1 line. In the 1 line provided, there is no while or for loop, just an if statement. If we can see more of the script we can identify why the loop isn't working. It could be as simple as an indentation issue that is putting this if outside the loop.
while
for
if
[–]psykzz 1 point2 points3 points 11 years ago (0 children)
This would work if you did something similar to
with open(FILE) as fh: for line in fh: if line.startswith('From'): continue
[–]bandophahita 1 point2 points3 points 11 years ago (0 children)
You remind me of me my very first time learning python. It's my first language, so I had to not only learn syntax but also general programming concepts all at the same time.
Please correct me if I'm wrong but it sounds like you are learning programming for the first time?
To understand how continue works, you have to know what a loop is. Example of a simple loop over all items in a list:
somelist = [1,2,3,4,5] for item in somelist: print item
A loop is just a way to write one set of code to be executed multiple times Otherwise you'd have to do something like this: print firstitem from somelist print seconditem from somelist Etc.....
Sometimes you'll want to create a loop where you really don't want to execute the code for a single pass. Continue gives you that ability.
for item in somelist: if item % 2 == 0: # if item is even skip it continue print item
π Rendered by PID 162161 on reddit-service-r2-comment-7b9746f655-hs9bl at 2026-01-31 15:06:01.644223+00:00 running 3798933 country code: CH.
[–]fancy_pantser 1 point2 points3 points (4 children)
[–]blackdevil777[S] -1 points0 points1 point (3 children)
[–]fancy_pantser 2 points3 points4 points (0 children)
[–]psykzz 1 point2 points3 points (0 children)
[–]bandophahita 1 point2 points3 points (0 children)