generate a list of variables with two indices [closed]

asked 2019-04-16 02:25:03 -0500

ortollj gravatar image


I would like to make a list of variables with two consecutive indices, example rr_10, rr_21 .. etc I tried :

rrL=list(var('rr_%d%d' %i %(i-1)) for i in [1..n])

without success:not enough arguments for format string what is the missing arguments here ?

edit retag flag offensive reopen merge delete

Closed for the following reason not a real question by ortollj
close date 2019-04-16 02:30:13.161587


Oops ok , I find a way Sorry, Im gonna close the subject !

rrL=list(var('rr_%d'  %i +'%d' %(i-1)) for i in [1..n])
ortollj gravatar imageortollj ( 2019-04-16 02:29:29 -0500 )edit


["rr_%d%d"%(i,i-1) for i in [1..n]]

is the right solution

nbruin gravatar imagenbruin ( 2019-04-16 21:24:14 -0500 )edit

thank you nbruin, finally it was a true question !, i'm gonna reopen it and mark your comment as answer.

ortollj gravatar imageortollj ( 2019-04-18 01:44:08 -0500 )edit

but it is not possible for me to transform your comment in good answer !

ortollj gravatar imageortollj ( 2019-04-18 01:52:39 -0500 )edit