Runtime Error: Attempt to get item number 2 of a list of length 1: (1)

Please help, I am working on a project for my school and we all have not been able to get this part to work. We are trying to build an app where users can select a ice cream flavor from a list and it will allow uses to vote and show up on a list viewer. However when we click vote, we get the following message.
Screenshot 2022-12-09 8.08.26 AM
Attached is the code we have used:

Thank you in advance. :slight_smile:

votelist only have 1 item?

This would be much simpler if you used a TinyDB or dictionary with flavors as keys or tags and vote counts (default 0) as values.

The curriculum we use forces us to use lists because it "teaches" use how to use lists in this lesson. So that is sadly not an option. :confused:

Yes. The reference code that works says it should have this.

In such case you should not use select list item list in procedure instead use set global votter list

The error is in here:
and here:

When you initialize the program, VoteList is assigned one element: [0]. You are getting the index of flavor_list, which has many elements; to replace that same index in VoteList, which has one element.

If you want a separate list element in VoteList for each element in flavor_list, you should initialize VoteList with ten elements (all of which have 0 as their value); respectively as flavor_list also has ten elements.

Hope this helps. :grinning:

That worked!! Thank you so much, I don't know how I missed that. :sweat_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.