Q:

python: casting to upper and finding string

i am getting stuck on this line:
row[1].upper().find('CELEBREX',1) (this is returning -1)
it seems to not find CELEBREX even though it is there
row[1] = 'celebrex, TRAMADOL'

am i casting to UPPER incorrectly?

A:

The second argument of find() shouldn't be 1, because it will start search after the first character of the string.
>>> s = 'celebrex, TRAMADOL'
>>> print s.upper().find('CELEBREX')
0

Find() will return 0 because it found the first match at position 0, the first position in the string. So it's important to note that, as you've already discovered, the if find() doesn't find the string, it will return -1. Return value 0 is actually a match.

