num ws for line in enumerate ws sys stdout write Fw sys stdout write l

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
num = 1
ws = [[0], [3, 4, 6], [5, 7, 8], [1, 2], [9]]
for i, line in enumerate(ws):
sys.stdout.write('Fw%d = ' % i)
sys.stdout.write('{V%d' % (line[0] + num))
for item in line[1:]:
sys.stdout.write(', V%d' % (item + num))
sys.stdout.write('}\n')
for i, line in enumerate(ws):
print 'Fw%d =' % i,
print '{V%d' % (line[0] + num),
for item in line[1:]:
print ', V%d' % (item + num),
print '}'
Fw0 = {V1}
Fw1 = {V4, V5, V7}
Fw2 = {V6, V8, V9}
Fw3 = {V2, V3}
Fw4 = {V10}
Fw0 = {V1 }
Fw1 = {V4 , V5 , V7 }
Fw2 = {V6 , V8 , V9 }
Fw3 = {V2 , V3 }
Fw4 = {V10 }