How to resolve AttributeError: 'list' object has no attribute 'next' in Python
<p>I am trying to read a file where the odd lines are department numbers, and even ones are sales totals.  I need to be able to read a line and append it to a variable to be used later.</p>

<pre><code>def main():
    with open('P2data.txt') as x:
        data = x.readlines()    
        dept = (data)[::2]    
        sales = (data)[1::2]   
    if dept == '1':
        total = sales.next()
        total.append(total1)
    elif dept == '2':
        total = sales.next()
        total.append(total2)
    else:
        total = sales.next()
        total.append(total3)
    print('Dept 1:', total1)
    print('Dept 2:', total2)
    print('Dept 3:', total3)
main()
</code></pre>