generate a list of variables with two indices [closed]

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

ortollj gravatar image

Hi

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

n=3
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

Comments

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

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

this:

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

is the right solution

nbruin gravatar imagenbruin ( 2019-04-16 21:24:14 -0600 )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 -0600 )edit

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

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