Ask Your Question

collegesista's profile - activity

2022-04-14 20:07:30 +0200 received badge  Famous Question (source)
2019-07-02 13:02:26 +0200 received badge  Notable Question (source)
2018-09-23 18:20:25 +0200 received badge  Popular Question (source)
2017-02-25 04:05:55 +0200 asked a question Iterating over list of tuples

I am attempting to index into the y-coordinates of each tuple to count how many tuples have a y-coordinate of 0, 1, or 2 but am receiving an error message which looks like this:

Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 982, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> TypeError: 'sage.rings.integer.Integer' object is not iterable

My code is below:

zero_count, one_count, two_count = 0

for i in range(len([list])):
    if list[i][1] == 0:
        zero_count += 1
    elif list[i][1] == 1:
        one_count += 1
    else:
        two_count += 1