Andrew.B
Andrew.B

Reputation: 11

what is this? (unexpected character after line continuation character)

for x in range(len(s.body)):
        if s.body[x].pos in list(map(lambda z:z.pos,s.body[x+1:])):
            print(\'Score: \', len(s.body))
            message_box(\'You Lost!\', \'Play again...\')
            s.reset((10,10))
            break 

It seems fine to me, but i cant seem to find the error.

Upvotes: 1

Views: 82

Answers (1)

hzahnuwen
hzahnuwen

Reputation: 156

The single quotation mark ' is written as \' in your code (perhaps due to copying?) Simply run

for x in range(len(s.body)):
        if s.body[x].pos in list(map(lambda z:z.pos,s.body[x+1:])):
            print('Score: ', len(s.body))
            message_box('You Lost!', 'Play again...')
            s.reset((10,10))
            break 

\ is the "line continuation character" in Python that continues a line to the next line, which is not expected here.

Upvotes: 2

Related Questions