SyntaxError: invalid syntax (on else)
Any help?

import re
words = ['cats', 'cates', 'dog', 'ship']
for l in words:
    m = re.search( r'cat..', l)
    if m:
        print l
        else:
            print 'none'

The identation of 'else' must be exactly the same as the corresponding 'if'

import re
words = ['cats', 'cates', 'dog', 'ship']
for l in words:
    m = re.search( r'cat..', l)
    if m:
        print l
    else:
        print 'none'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.