# Python List Comprehensions Help

**URL:** <https://forum.inductiveautomation.com/t/python-list-comprehensions-help/56621>\
**Category:** Ignition\
**Created:** [February 28, 2022, 3:12pm UTC](https://forum.inductiveautomation.com/t/python-list-comprehensions-help/56621 "2022-02-28T15:12:54Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 28, 2022, 9:18pm UTC](https://forum.inductiveautomation.com/t/python-list-comprehensions-help/56621/14 "2022-02-28T21:18:52Z")

</div>

This is why I recommend looking at the tag quality.  
In my example I have three tags, ‘Tag 01, Tag 02, and Tag 04’. The processing portion only pays attention to those qualities that are good.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/d/6dd7a8361b2b54ad4f7077ed29dd67ddb90bce27.png)

```python
numberOfTags = 4
baseTagPath = '[Test]Tag {0:02d}'

tagPaths = [baseTagPath.format(i) for i in xrange(1, numberOfTags+1)]
valuesIn = system.tag.readBlocking(tagPaths)

print 'Tags In'
for tag, qVal in zip(tagPaths, valuesIn):
	print tag, ':', qVal

# Processing
tagsOut = []
valuesOut = []

for tag, qValue in zip(tagPaths, valuesIn):
	if 'Good' in str(qValue.quality):
		tagsOut.append(tag)
		valuesOut.append(qValue.value + 5)
		
print 'Tags Out'
for tag, val in zip(tagsOut, valuesOut):
	print tag, ':', val
numberOfTags = 4
baseTagPath = '[Test]Tag {0:02d}'

tagPaths = [baseTagPath.format(i) for i in xrange(1, numberOfTags+1)]
valuesIn = system.tag.readBlocking(tagPaths)

print 'Tags In'
for tag, qVal in zip(tagPaths, valuesIn):
	print tag, ':', qVal

# Processing
tagsOut = []
valuesOut = []
for tag, qValue in zip(tagPaths, valuesIn):
	if 'Good' in str(qValue.quality):
		tagsOut.append(tag)
		valuesOut.append(qValue.value + 5)
print '\n-----------\n\nTags Out'		
for tag, val in zip(tagsOut, valuesOut):
	print tag, ':', val

```

Output

```nohighlight
>>> 
Tags In
[Test]Tag 01 : [10, Good, Mon Feb 28 15:11:26 EST 2022 (1646079086152)]
[Test]Tag 02 : [20, Good, Mon Feb 28 15:11:28 EST 2022 (1646079088784)]
[Test]Tag 03 : [null, Bad_NotFound("Path '[Test]Tag 03' not found."), Wed Feb 16 12:47:37 EST 2022 (1645033657329)]
[Test]Tag 04 : [40, Good, Mon Feb 28 16:05:57 EST 2022 (1646082357934)]

-----------

Tags Out
[Test]Tag 01 : 15
[Test]Tag 02 : 25
[Test]Tag 04 : 45
>>> 

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/python-list-comprehensions-help/56621)._
