partition - Sage ('Python-like' language) Attribute error "IntegerListsLex_with_category.element_class" object -


given integer k, have programmed way take partitions of k such that

(1) each partition has @ n entries (where n given)

(2) each partition not have repeated odd numbers.

i categorized list of these partitions in descending order. however, unable append zeros end of given partition in list such partitions n-tuples.

# define n , k (k, n) = (10, 5)  # find partitions of k of max length n, , put partitions in list b b = partitions(k, max_length=n).list()  # extracts partitions repeated odd components , creates separate list them, namely b_repeated_odds b_repeated_odds = [] in range(0, len(b)):     j in range(0, len(b[i])):         l in range(0, len(b[i])):             if b[i][j]%2 == 1:                 if b[i][l]%2 == 1:                     if b[i][j] == b[i][l]:                         if j != l:                             b_repeated_odds.append(b[i])  # remove duplicates b_repeated_odds b_unique = uniq(b_repeated_odds)  # remove unwanted partitions original list b, , sort finalized list in descending order improper_part = set(b).difference(set(b_unique)) proper_part = sorted(improper_part, reverse=true)  in range(0, len(proper_part)):     while len(proper_part[i]) < n:         proper_part[i].append(0) 

the aforementioned issue occurs in last 3 lines of code, error message stating "attribute error: 'integerlistslex_with_category.element_class' object has no attribute 'append'."

my question how can change types of partitions within list proper_part integerlistslex_with_category.element_class list (or other object append command applicable)? or if sees better approach, i'd love hear it.

to answer own question, suitable replacement bottom 3 lines of code following:

# convert each partition integerlistslex_with_category.element object list  c = []  in range(0, len(proper_part)):      c.append(list(proper_part[i]))      while len(c[i]) < n:          c[i].append(0) 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo