On Oct 29, 2013 7:18 PM, "Alex Tenno" <alex.te...@gmail.com> wrote: > > Hey everyone, > > I'm encountering a problem with a python function that I am supposed to create. I want my function to look at a string, and then replace each letter in the string with its relative position in the alphabet. for example, 'abcde' would return '12345', 'zabd' would return '4123', and 'xpft' would return '4213'. I have been given hints that tell me "You may want to iterate over the letters ch in s as in the for loop above, and inside that for loop, count the number of letters that are in s and come before the loop variable ch. You will also need an accumulator to build the permutation the function will return." any help would be greatly appreciated.
Have you thought on the lines of sorting the string and checking what position each letter of the original string is in the sorted string? For eg. 'zabd' sorted would be 'abdz' and you can check which position 'z' is in and so on. Hope that helps. Best, Amit. > > Many thanks! > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor