#๐ Is there an easier way to do this?
41 messages ยท Page 1 of 1 (latest)
@mighty ridge
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
u want a sliding window
Yes
u can configure size however u want
so 1,15,1
then 2,6,12
if u understand how it works with 4 elements u can just make it work for 3 with a adjustment of just a number
the length is not my problem, it needs to be exclusive.
anyways, there is tons of different ways to do this, how much python experience u got and do u know list slicing 
oh not usual sliding window then
I got usual sliding window using this
for index,item in enumerate(colm1):
try:
print(item,colm1[index+1],colm1[index+2])
except IndexError:
pass
usually using range is easier for these kind of needs
because we already doing everything based on index, so just makes life easier
for i in range(0,len(colm1),3):
print(colm1[i])
print(colm1[i+1])
print(colm1[i+2])
!e
colm1 = [1,15,1,2,6,12]
for i in range(0,len(colm1),3):
print(colm1[i])
print(colm1[i+1])
print(colm1[i+2])
print()
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 | 1
002 | 15
003 | 1
004 |
005 | 2
006 | 6
007 | 12
it works 
easier way is slicing
show
oh wait i got it
!e
colm1 = [1,15,1,2,6,12]
print(colm1[0:5:2])
:white_check_mark: Your 3.13 eval job has completed with return code 0.
[1, 1, 6]
for i in range(0,len(colm1),3):
print(colm1[i:i+3])
ok thanks, im kinda new
it just didn't come to mind
every1 starts somewhere 
ya welcome
.close
!close
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.