If I have {1,2,3,4,5,6}, how do I take all the second elements into a new list? So I want a list like {2,4,6}.
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack InternalIf I have {1,2,3,4,5,6}, how do I take all the second elements into a new list? So I want a list like {2,4,6}.
list={1,2,3,4,5,6}; list[[2;; ;;2]].Extract[list, Range[2,Length@list,2].Partition[list, 2][[All, 2]]. Etc. $\endgroup$Take, which is the function. If you use the free-form input to "take every second element fromlist", you get%[[1 ;; -1 ;; 2]], which is easily adapted. $\endgroup$Span, just type?Spaninto your notebook to get the information on how to use it. $\endgroup$