+ 2

Can someone help me fix this dumb question?

u=list() def CalculFiboTupleIt( (a,b),(u,u1),n): global u for i in range(2,n): u[i]=-a*u[i-1]-b*u[i-2] return u[n-1] print(CalculFiboTupleIt((-1,-1),(0,1),6)) My computer shows an error message when I try to run this code... Why? The error message is: File "<tmp 4>", line 1 def tuple((a,b),n): ^ SyntaxError: invalid syntax

10th Dec 2019, 4:30 PM
Suzanne
Suzanne - avatar
2 Respostas
+ 2
You can't have function parameters within tuples, or lists, etc. You can do this, however: def tuple(a,b,n): ... where a and b are tuples. Of course, you'd need to use a[0], a[1], etc. to access the elements within them in the function.
10th Dec 2019, 5:14 PM
Russ
Russ - avatar
0
Thanks!!
27th Dec 2019, 11:35 AM
Suzanne
Suzanne - avatar