Python for statement giving an Invalid Syntax error with list

Posted by Cold Diamondz on Stack Overflow See other posts from Stack Overflow or by Cold Diamondz
Published on 2013-11-06T21:41:28Z Indexed on 2013/11/06 21:53 UTC
Read the original article Hit count: 211

Filed under:

I have some code in which is throwing an error (I'm using repl.it)

import random
students = ['s1:0','s2:0','s3:0']
while True:
    print'\n'*50
    print'Ticket Machine'.center(80)
    print'-'*80
    print'1. Clear Student Ticket Values'.center(80)
    print'2. Draw Tickets'.center(80)
    menu = raw_input('-'*80+'\nChoose an Option: ')
    if menu == '1': 
        print'\n'*50
        print'CLEARED!'
        students = ['s1:0','s2:0','s3:0']
        raw_input('Press enter to return to the main menu!')
    elif menu == '2':
        tickets = []
        print'\n'*50
        times = int(raw_input('How many tickets to draw? ')
        for a in students:
            for i in range(a.split(':')[1]):
                tickets.append(a.split(':')[0])
        for b in range(1,times+1):
            print str(b) + '. ' + random.choice(tickets)
    else:    
        print'\n'*50
        print'That was not an option!'
        raw_input('Press enter to return to the main menu!')

But it is throwing this error:

File "<stdin>", line 19
    for a in students:
                     ^
SyntaxError: invalid syntax

I am planning on using this in a class, but I can't use it until the bug is fixed, also, student names have been removed for privacy reasons.

© Stack Overflow or respective owner

Related posts about python-2.7