Steven, Walter, Dave, Peter and Albert, First of all, thank you very much for your suggestions, I appreciate a lot your help. I would only like to mention that I would have never asked something to be done for me just because it's my homework, I posted this question only because I couldn't find a solution myself and I was dying from curiosity how to do it. For me it makes no difference if it was homework or not, because it's practice first of all, I'm not studying for marks, that's why I was surprised to know that I should have specified it.
So, yesterday I was so upset that I couldn't make it work that I went to bed and gave it up for a while :) But then I came up with the solution similar to that proposed by Walter and Peter, i.e. list all the letters in alphabetical order marked by "*": [a*b*c*d*...x*y*z*] - with the only difference that I don't need to mark the beginning and the end of the line, because I first tokenized my text and I work with a single word (and it's supposed that the word is well-formed, without punctuation marks attached to it or empty strings or something) But naturally, this solution doesn't seem to be very elegant one (however, it might be exactly that solution that our teacher supposed us to find) I think, that I leave it like this till I find something more elegant if it's possible at all. I would know if or how it could be done with regexes, but isn't the > following simple code a solution? It requires that the text be split up > into separate words. Or am I overlooking something? > >>word = 'ym' > >>> [letter for n, letter in enumerate(word) if letter > word[n-1]] == > list(word[1:]) > False > >>word = 'almost' > >>> [letter for n, letter in enumerate(word) if letter > word[n-1]] == > list(word[1:]) > True Albert, concerning your question - yes, the text is tokenized to separate words. Thank you for your suggestion! I'm trying to understand how it works now :) Kind Regards, Dinara 2011/11/5 Albert-Jan Roskam <fo...@yahoo.com> > Hi, > > I would know if or how it could be done with regexes, but isn't the > following simple code a solution? It requires that the text be split up > into separate words. Or am I overlooking something? > >>word = 'ym' > >>> [letter for n, letter in enumerate(word) if letter > word[n-1]] == > list(word[1:]) > False > >>word = 'almost' > >>> [letter for n, letter in enumerate(word) if letter > word[n-1]] == > list(word[1:]) > True > > Cheers!! > Albert-Jan >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor