## Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.  # list index out of range and how to do a task

Hi, I am in the middle of writing my code and I don't know why it says that the list index is out of range... if I add one to my index in first iteration(and in the beginning it is equal zero) then it should be equal one which clearly can't be out of range... (I want to write a function that: accepts a 6 element list entered by the user Checks if adjacent items have the same value If condition 2 is met, it sums them up together. If the condition does not apply, it squares the third element. It indicates which number appeared the most times in the list and gives the number of its occurrences) Example: Input: [3,2,3,3,3,3] Output: 12 Number most frequently appearing in the list: 3 Number of occurrences of the most frequently appearing in the list: 5 Ps. I wanted to put it in a function later...

```#receiving a list from the user
lst = []
amount = 0
for i in range(0, 6):
ele = int(input())
lst.append(ele)
#checking if the adjacent numbers are equal
while(lst[i]==lst[i+1]):
amount += lst[i]
else:
amount = lst*lst

print(lst)
``` The loop adds a single element to the list in each pass, (index "i"), but the "while" code accesses both `lst[i]` and `lst[i+1]`. So for every pass, `lst[i+1]` is attempting to access an element that does not yet exist, and is therefore "out of range". 