ProbEnthought Canopylems with - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: ProbEnthought Canopylems with (/thread-15484.html) |
ProbEnthought Canopylems with - kendias - Jan-19-2019 I am having problems with Enthought Canopy, whatever my code I get error e.g. for this program I get return [l] ^ IndentationError: unexpected indent although this is a program already published: def perm(l): # Compute the list of all permutations of l if len(l) == 1: print len return [l] r = [1] print r for i in range(len(l)): s = l[:i] + l[i+1:] p = perm(s) for x in p: r.append(l[i:i+1] + x) return r RE: ProbEnthought Canopylems with - perfringo - Jan-19-2019 Some observations: - you (probably) use Python 2. I suggest to switch to Python 3. Python 2 is EOL at the end of this year - as stated in error - there should be no intent. Return statement must be on same level as previous row (row #4). - you have statement 'print len', assuming that this is Python 2 it works but output will be <built-in function len> . Is it what you want?- Python intentation is 4 spaces - if you need permutations then have a look at built-in module itertools and function defined there itertools.permutations(). There is code provided how permutations function (roughly) works. RE: ProbEnthought Canopylems with - kendias - Jan-19-2019 Thanks! Works now. RE: ProbEnthought Canopylems with - kendias - Jan-19-2019 This also does not work - Syntax error. Kindly help.: soup = BeautifulSoup(xml, 'html.parser') lat = soup.find('latitude') <lat> <latitude>1.123123</latitude> </lat> print((lat.text)) #1.123123 |