MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/PowerShell/comments/iuifz8/powershell_vs_python_reference/g5l275h/?context=3
r/PowerShell • u/[deleted] • Sep 17 '20
51 comments sorted by
View all comments
5
Does powershell have something like python's list comprehension?
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print(a[1:10:2])
2 u/setmehigh Sep 17 '20 What does that do? 3 u/HeKis4 Sep 17 '20 Gets every other list elements from the 1st to the 10th (0-indexed of course, we're not savages).As a for loop, it would look like for(int i=1; i<10; i+=2) { a[i] }
2
What does that do?
3 u/HeKis4 Sep 17 '20 Gets every other list elements from the 1st to the 10th (0-indexed of course, we're not savages).As a for loop, it would look like for(int i=1; i<10; i+=2) { a[i] }
3
Gets every other list elements from the 1st to the 10th (0-indexed of course, we're not savages).
As a for loop, it would look like for(int i=1; i<10; i+=2) { a[i] }
for(int i=1; i<10; i+=2) { a[i] }
5
u/prp7 Sep 17 '20
Does powershell have something like python's list comprehension?