Guest User

Untitled

a guest
Feb 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. a = 0
  2. SMAlist = []
  3. for each_item in y:
  4. if a > 4 and a < ((len(y))-1): # finding my averages begin at 6th item
  5. b = (y[a-5:a+1]) # this line doesn't work for the last item in y
  6. SMAsix = round((sum(b)/6),2)
  7. SMAlist.append(SMAsix)
  8. if a > ((len(y))-2): # this line seems unnecessary. How can I avoid it?
  9. b = (y[-6:-1]+[y[a]]) # Should I just use negative values in general?
  10. SMAsix = round((sum(b)/6),2)
  11. SMAlist.append(SMAsix)
  12. a = a+1
Add Comment
Please, Sign In to add comment