Runtime error with my Python version, any suggestion?


  • 0
    I

    Runtime Error Message: Line 33: AttributeError: Solution instance has no attribute 'generate'
    Last executed input: 0

    def get_next(l):
    l_next = []
    if l != []:
    	l_next.append(l[0])
    else:
    	return []
    for i in range(0, len(l)-1):
    	l_next.append(l[i] + l[i+1])
    l_next.append(l[len(l)-1])
    return l_next
    
    
    class Solution:
    # @return a list of lists of integers
    def print_pascal_triangle(self, numRows):
    	result = []
    	tmp = []
    	if numRows <= 0:
    	    return result
    	tmp.append(1)
    	result.append(tmp)
    	if numRows == 1:
    		return result
    	else:
    		for x in range(1, numRows):
    			tmp = get_next(tmp)
    			result.append(tmp)
    	return result

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.