python check value not in unicode list

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-05-13T10:06:32Z Indexed on 2010/05/13 10:14 UTC
Read the original article Hit count: 122

Filed under:

Hi,

I have a list and a value and want to check if the value is not in the list.

list = [u'first record', u'second record']
value = 'first record'

if value not in list:
    do something

however this is not working and I think it has something to do with the list values having a u at the start, how can I fix this? And before someone suggests the list is returned from Django queryset so I can't just take the u out of the code :)

Thanks

© Stack Overflow or respective owner

Related posts about python