<p dir="ltr"><br>
On Oct 29, 2013 7:18 PM, "Alex Tenno" <<a href="mailto:alex.tenno@gmail.com">alex.tenno@gmail.com</a>> wrote:<br>
><br>
> Hey everyone,<br>
><br>
> 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.</p>
<p dir="ltr">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?</p>
<p dir="ltr">For eg. 'zabd' sorted would be 'abdz' and you can check which position 'z' is in and so on.</p>
<p dir="ltr">Hope that helps.<br>
Best,<br>
Amit.<br>
><br>
> Many thanks!<br>
><br>
> _______________________________________________<br>
> Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
> To unsubscribe or change subscription options:<br>
> <a href="https://mail.python.org/mailman/listinfo/tutor">https://mail.python.org/mailman/listinfo/tutor</a><br>
><br>
</p>