Is there a method that returns a character at a specified index?
Ian Bicking
ianb at colorstudy.com
Sun Oct 26 22:55:52 EST 2003
More information about the Python-list mailing list
Sun Oct 26 22:55:52 EST 2003
- Previous message (by thread): Is there a method that returns a character at a specified index?
- Next message (by thread): Is there a method that returns a character at a specified index?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sunday, October 26, 2003, at 08:11 PM, Michael Loomington wrote: > Couldn't find anything here > http://www.python.org/doc/2.3.2/lib/string-methods.html > > I need to cycle through lines in a file that contain words and compare > it to > a string thats given, call it SSS to see if the words in the file can > be > written from SSS. I am planning to grab each letter from the word one > at a > time and removing it from SSS and if the letter doesn't exist then I > will go > on to the next word. That's why I need a method that returns a letter > at > each index. Maybe there an easier way of doing this. You mean like: >>> "python"[0] "p" >>> "python"[1] "y" ? Though from what you say, regular expressions are what you are looking for. For example, to check if a string contains only letters: re.search(r'^[a-z]+$', word). Or re.search("^[%s]+$" % re.escape(SSS), word). -- Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org
- Previous message (by thread): Is there a method that returns a character at a specified index?
- Next message (by thread): Is there a method that returns a character at a specified index?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list