You can do these things with xinttools. The \xintFor/\xintFor* loops do not create groups. On the other hand, they do not currently implement some nice \foreach syntax like 1, 2, ..., 5. And there is no easy way to create key=value selection as xinttools is not a full-fledged programming interface like provided by LaTeX3, but a small collection of useful macros (usable under Plain TeX, too).
\documentclass{article}
\usepackage{xinttools}
\usepackage{parskip}
\begin{document}\pagestyle{empty}\thispagestyle{empty}
\section*{Cutting a loop off at some number}
First three:
\begin{itemize}
% this uses \xintFor* as argument will be {item1}{item2}....
% i.e. a "list" in the sense of xinttools doc, not a
% "comma separated list"
\xintFor* #1 in {\xintKeep{3}{\xintCSVtoList{10,20,30,40,50}}}
\do
{\item (Item: #1)}
\end{itemize}
Last two:
\begin{itemize}
\xintFor* #1 in {\xintKeep{-2}{\xintCSVtoList{10,20,30,40,50}}}
\do
{\item (Item: #1)}
\end{itemize}
Trim first two:
\begin{itemize}
\xintFor* #1 in {\xintTrim{2}{\xintCSVtoList{10,20,30,40,50}}}
\do
{\item (Item: #1)}
\end{itemize}
Trim last two:
\begin{itemize}
\xintFor* #1 in {\xintTrim{-2}{\xintCSVtoList{10,20,30,40,50}}}
\do
{\item (Item: #1)}
\end{itemize}
Nested keep/trim (keep 2 after having trimmed 2):
\begin{itemize}
\xintFor* #1 in {\xintKeep{2}{\xintTrim{2}{\xintCSVtoList{10,20,30,40,50}}}}
\do
{\item (Item: #1)}
\end{itemize}
\clearpage
\section*{Selecting a subset of items from a list}
Selecting items 1, 3, 4, 2, 5, 5:
% for better efficiency, let's convert comma separated values
% in a "list" (in xinttools terminology) first, once and for all
% because \xintNthElt macro expects such as list
\oodef\MyListOfBracedItems{\xintCSVtoList{10,20,30,40,50}}
\begin{itemize}
% this uses the non-starred \xintFor, which accepts comma separated values
\xintFor #1 in {1, 3, 4, 2, 5, 5}
\do
{\item (Item: \xintNthElt{#1}{\MyListOfBracedItems})}
\end{itemize}
It is also possible to create an ``array'', for better efficiency afterwards:
\xintAssignArray\xintCSVtoList{10, 20, 30, 40, 50}\to\MyArray
\begin{itemize}
% this uses the starred \xintFor, which accepts braced items (or
% single tokens; spaces skipped)
\xintFor* #1 in {1 3 4 2 5 5}
\do
{\item (Item: \MyArray{#1})}
\end{itemize}
\end{document}
Page 1

Page 2

\forparteach 3picking every third element and not just the (single) 3rd element? – Werner Sep 09 '18 at 17:04