Stupid question, just need a quick and dirty fix
Cousin Stanley
cousinstanley at gmail.com
Fri Jul 22 11:45:08 EDT 2016
Jordan Bayless wrote:
> ....
> desired = Id < 10 or Id > 133 or Id in good_ids
>
> When I try to validate whether I passed that check,
> I'm told there's a Name error and it's not defined
> ....
On the outside chance that failing to define Id
produces the Name error, I defined Id in a for loop
as a test for your copy/pasted code ....
$ cat id_test.py
#!/usr/bin/env python3
good_ids = {
2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 24, 25, 26, 27, 28, 31, 34, 35, 36, 37,
38, 39, 40, 45, 50, 51, 53, 55, 56, 57, 59, 62, 65, 68, 71, 76, 78, 80,
82, 83, 87, 88, 89, 91, 93, 94, 96, 97, 101, 103, 105, 106, 107, 109,
110, 112, 113, 115, 122, 124, 125, 126, 130, 131, 132, 134, 135, 136,
137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
151
}
test_ids = [ 1 , 10 , 128 , 42 , 137 , 444 ]
print( )
for Id in test_ids :
desired = Id < 10 or Id > 133 or Id in good_ids
print( ' Id : %4d .... desired : %s ' % ( Id , desired ) )
$ ./id_test.py
Id : 1 .... desired : True
Id : 10 .... desired : False
Id : 128 .... desired : False
Id : 42 .... desired : False
Id : 137 .... desired : True
Id : 444 .... desired : True
--
Stanley C. Kitching
Human Being
Phoenix, Arizona
More information about the Python-list
mailing list