Need to calculate total distance traveled in a 2D random walk

Part1
s = {0., 0.};
path = Table[s += RandomReal[{-0.5, 0.5}, 2], {100}];
ListLinePlot[path, ImageSize -> Small]
path


This part of the code generates 100 xy coordinates or steps and I need a code to calculate total distance with a DO loop

• Welcome to MSE. Is this a homework question? If so, please add the "homework" tag and update your post with the ideas and/or code you have used to try and solve the problem. – Rohit Namjoshi Feb 7 at 2:21

SeedRandom[1]
s = 0; path = Table[s += RandomReal[{-0.5, 0.5}, 2], {100}];


You can use ArcLength or RegionMeasure:

ArcLength[Line@path]


36.96705

RegionMeasure[Line@path]


36.96705

With

path = Accumulate@Prepend[RandomReal[{-0.5, 0.5}, {100, 2}], {0, 0}];


here are a couple of possibilities:

EuclideanDistance @@@ Partition[path, 2, 1] // Total
BlockMap[EuclideanDistance @@ # &, path, 2, 1] // Total