NIH
NIH

Reputation: 161

Check if a character equals quotes in python

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?

Upvotes: 5

Views: 28785

Answers (1)

Cameron
Cameron

Reputation: 98836

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('"')

Upvotes: 11

Related Questions