Brett Quiason Brett Quiason - 25 days ago 7
Python Question

Produce a range of '..' separated numbers

I would like a string like

0..1..2..3..4


So far what I have come up with is
a = list(range(5))
, however I need it to output in the format of
'#,#,#,#'


so I thought oh this is just a string format so I just did
a = str(list(range(5)))
, but this just makes a
[#,#,#,#]
a string.

Im not sure if I am just missing a simple function, or if using
range
is the correct function.

Answer Source

You can join a list of number strings.

>>> "..".join(map(str, range(5)))
'0..1..2..3..4'