I am a newbie and seeking for the Zen of Python 🙂 Today’s koan was finding the most Pythonesq way to solve the following problem:
Permute the letters of a string pairwise, e.g.
input: 'abcdefgh' output: 'badcfehg'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’d go for:
s[start:end:step] takes every step’th letter, zip matches them up pairwise, the loop swaps them, and the join gives you back a string.