2021-03-30 19:32:53 +0200 marked best answer How to build a generating series Hello. Forgive me, I'm still a bit new to coding. I want to create a generating q-series for functions I've already defined, which have complex number outputs. These functions are denoted g(k, n, z), where k, n are integers and z in a complex input. I'd like the series sum([g(k, n, z)*q^n for n in range(1, 100)]) or something along those lines. The error code is: --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in 5 return sum([g(k, n, z)*q**n for n in range(Integer(1), Integer(100))]) 6 ----> 7 G(Integer(2), Integer(1)+i) in G(k, z) 3 def G(k, z): 4 var('q') ----> 5 return sum([g(k, n, z)*q**n for n in range(Integer(1), Integer(100))]) 6 7 G(Integer(2), Integer(1)+i) in (.0) 3 def G(k, z): 4 var('q') ----> 5 return sum([g(k, n, z)*q**n for n in range(Integer(1), Integer(100))]) 6 7 G(Integer(2), Integer(1)+i) TypeError: unsupported operand type(s) for *: 'NoneType' and 'sage.symbolic.expression.Expression  I apologize I cannot make the above formatting more clear. Perhaps someone could help me! Edit: Thank you for editing above error code! 2021-03-30 19:32:51 +0200 commented answer How to build a generating series I added var('q') in the def of G and also used your advice about return. This seemed to work! Thank you! 2021-03-30 17:57:56 +0200 edited question How to build a generating series How to build a generating series Hello. Forgive me, I'm still a bit new to coding. I want to create a generating q-serie 2021-03-30 17:26:09 +0200 asked a question How to build a generating series How to build a generating series Hello. Forgive me, I'm still a bit new to coding. I want to create a generating q-serie 2021-01-20 00:33:57 +0200 commented answer Print scaling factors in eta-products Very nice. Did not know this function. Thank you! 2021-01-20 00:33:45 +0200 received badge ● Scholar (source) 2021-01-19 01:03:30 +0200 asked a question Print scaling factors in eta-products I have the useful command: EtaGroup(8).basis().r(2)  which will return the first exponent in (eta_2)^-4 (eta_4)^12 (eta_8)^-8; namely -4. Similarly EtaGroup(8).basis().r(4)  will return 12 etc. I want to extract the scaling factors though. That is, I want to print 2 or 4 or 8 in the expression (eta_2)^-4 (eta_4)^12 (eta_8)^-8 How?? 2020-04-22 14:53:42 +0200 received badge ● Good Question (source) 2020-03-27 00:53:02 +0200 received badge ● Supporter (source) 2020-03-27 00:52:59 +0200 commented answer How to do arithmetic with a basis element from modular forms space It worked!!! So when I do print(g.q_expansion()*L.q_expansion) something goes wrong, but leaving out "print" seems to fix this... weird. 2020-03-25 16:21:06 +0200 commented answer How to do arithmetic with a basis element from modular forms space Yes, but if I try something like g*L.q_expansion() or g*L.qexp(20) or things like that I get that error. 2020-03-25 16:19:19 +0200 commented question How to do arithmetic with a basis element from modular forms space Yes, sorry. It's L = EtaProduct(7, {1:4, 7:-4}). I also mixed up the level on accident but edited to fix. It's 7. 2020-03-25 16:18:07 +0200 received badge ● Editor (source) 2020-03-24 09:01:35 +0200 received badge ● Nice Question (source) 2020-03-23 21:24:39 +0200 received badge ● Student (source) 2020-03-23 20:08:30 +0200 asked a question How to do arithmetic with a basis element from modular forms space Hi, I'm new to Sage and coding in general. I want to look at the 1-dim'l space CuspForms(Gamma0(7), 3) but with character. Here's my code for that S = G = DirichletGroup(7, QQ) list(G) G.gens() e = G.0 S = CuspForms(e, 3, prec=20) print(S) print(Gamma0(7).cusps()) print(S.basis()) g = S.0  Here, g is the only basis element for S. I want to do F = g*(L+4) where L is some eta-quotient of level 7. However, I get a long error with 'NoneType' object is not iterable at the end. So I'm thinking I need to define g in a different way, since it seems to be that g is not a q-series type object the way I've defined it?