Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if a character equals quotes in python

Tags:

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?

like image 352
NIH Avatar asked Dec 16 '22 13:12

NIH


1 Answers

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('"')
like image 185
Cameron Avatar answered Dec 28 '22 23:12

Cameron