Fix Python – Finding all possible permutations of a given string in python

I have a string. I want to generate all permutations from that string, by changing the order of characters in it. For example, say:
x=’stack’

what I want is a list like this,
l=[‘stack’,’satck’,’sackt’…….]

Currently I am iterating on the list cast of the string, picking 2 letters randomly and transposing them to form a new string, and adding….

Fix Python – Why is str.translate much faster in Python 3.5 compared to Python 3.4?

I was trying to remove unwanted characters from a given string using text.translate() in Python 3.4.
The minimal code is:
import sys
s = ‘abcde12345@#@$#%$’
mapper = dict.fromkeys(i for i in range(sys.maxunicode) if chr(i) in ‘@#$’)
print(s.translate(mapper))

It works as expected. However the same program when executed in Python 3.4 and Python 3….

Fix Python – Python – Join with newline

In the Python console, when I type:
>>> “\n”.join([‘I’, ‘would’, ‘expect’, ‘multiple’, ‘lines’])

Gives:
‘I\nwould\nexpect\nmultiple\nlines’

Though I’d expect to see such an output:
I
would
expect
multiple
lines

What am I missing here?
….