Python Forum

Full Version: error using 'continue' in my code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i get the error "continue not properly in loop". i cant find examples that dont use it like this...

i want the code to exit and 're-enter' the loop when it encounters 'continue', if you notice before the 'continuation' command, there is a variable assignment which i need.

whats the proper use of 'continuation' for this code? thanks

def cmp(row):
  if col['Close'] > col['prev']:
    col['trade2'] = '+'
    x = '+'
    continue
  elif col['Close'] < col['prev']:
    col['trade2'] = '-'
    x = '-'
    continue
  elif col['Close'] == col['prev']:
    col['trade2'] = x
You mentioned loop, where is the loop condition in the code you provided?