Q:

Python for-loop syntax

    for i in range(2, job_count+1):
        job_count_array['//form[@id='SubAvailSelectForm']/font/table[2]/tbody/tr[%d]/td[1]/small' % i] = sel.get_text("//form[@id='SubAvailSelectForm']/font/table[2]/tbody/tr[%d]/td[1]/small" % i)

I am getting a syntax error with the value side of this dictionary entry. Let me know what looks wrong to you. The interpreter is pointing to the % i). Thanks!

A:

Look at the syntax highlighting. You can’t just put a plain ol’ ' in your '-delimited string.
Escape them as \', or change your quotes to be consistent with the second string:
for i in range(2, job_count+1):
    job_count_array["//form[@id='SubAvailSelectForm']/font/table[2]/tbody/tr[%d]/td[1]/small" % i] = sel.get_text("//form[@id='SubAvailSelectForm']/font/table[2]/tbody/tr[%d]/td[1]/small" % i)

