A bug in my simple python program of lcs -


import numpy np def lcs(i, j):     global x, y, c              if <= 0 or j <= 0:         return 0     else:         if c[i][j] < 0:             if x[i - 1] == y[j - 1]:                 c[i][j] = lcs(i - 1, j - 1) + 1             else:                 m = lcs(i - 1, j)                 n = lcs(i, j - 1)                 print m, n                 c[i][j] = max(m, n)         else: return c[i][j] c = np.zeros((8, 8), int) c = c - 1 x = 'abcbdab' y = 'bdcaba' lcs(7, 6) print c 

the program has bugs lookup 'm','n',

the print results come 'none'

ex:

0 0 0 none 0 none 0 none none none 

then program occur error:

typeerror: long() argument must string or number, not 'nonetype' 

i don't know 'none' comes

i'm newer, thanks

i don't know 'none' comes

if don't return anything, return value of python function none.

in particular, don't return in if c[i][j] < 0: branch.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -