4

I am iterating through a string in python and I want to check each character to see if it equals ". How do I go about doing this?

Cameron
  • 96,106
  • 25
  • 196
  • 225
NIH
  • 151
  • 2
  • 2
  • 8

1 Answers1

12

Like this:

for c in theString:
    if c == '"':
        print 'Aha!'

You can also directly get the index of the first quote like so:

theString.index('"')
Cameron
  • 96,106
  • 25
  • 196
  • 225