String shuffle one liner

Shuffle in Python is done with random.shuffle (list), but when I try to do it with a string, I get angry, so I have to do list (strings) once, and None is returned, so it's messed up! I'm dead! However, I learned random.sample (), so I will live! !! have become random.sample () picks up from the target and returns a list of arbitrary length, so if you make it a lambda expression that receives it as a character string, it looks like this

Supercalifragilisticexpialidocious


Supercalifragilisticexpialidocious = lambda x: ''.join(random.sample(x ,len(x))

If you write one liner s='strings';''.join(__import__('random').sample(s,len(s)));

>>> for _ in 'Supercalifragilisticexpialidocious':
...     print(Supercalifragilisticexpialidocious('Supercalifragilisticexpialidocious'))
...
euirfetxipsailigusodlrlcaiipciSaco
Sodirupiliasgsiurfolapicceexitailc
ooiiscxeiurialaaceldgprpfitiulcisS
igiSaclepilcespuairioxcloaustirdif
iclcfllguporastecSxipiierodaiiausi
Saticaausridlfeocolcilpiipigxureis
Siitreasieaailirloccgsofxluudciipp
iaceliufaStrgiuiroceaxlosppiilidsc
scarllreoiiscdoxtugepaiaSifiicupli
fcigellraoispSpcloexiuiiudistaraic
cgirSdllicsoipcliuispoirataexeufia
tiiuieiclgclSdiaoeplsaorucapsiifxr
pacliiirxslSliiasgieotuufiacdrpeoc
llfscuoiairairlpcopseiSxiiudtgcaie
tipoguaidlecliirosifSaciarpseuicxl
iiaptfusriplosciagcaluexiSicriodel
ioiaxSdlpracluptgcieusrilfiaiicsoe
Saitallirpiudxfusieooigraiseccicpl
opuiocSalscrldriieiisiuetxfgacilpa
aidocalirxitgSieoscliiuiecuarplpfs
prasiriileofxedlosaiacgSipculticui
ipillafcuoslircaeieiiuasitpoScgxrd
ispilpreafitxsuiglcooiuiSeaidrccla
uiipxfSilrsdipoaiirsilaclutecaogec
siaeplipfociSliaierrtlugcdoasxcuii
aisioepieifioxagSsicltcdrcullpiaur
coasSlarlgocauritsilciideuippfiiex
slpeacpicarldegrtxiSiiiisuialooucf
ilpclcsipuuSageaacrfdosiexiriiloit
xrpuoilsfaocaaSeritdlpgsiliuiiecic
ulixlStidaaicsirlsieceougfaciirpop
cgtieloiiSpaaiileaiuduoxcifcslprrs
cruapiorigcaisidpifecelllatusxSiio
liiuSectioixclsioiigpaasclureprfad

Recommended Posts

String shuffle one liner
One liner in Python
python Zundko One Liner
One Liner Web Server
One Liner Zundco Check
One liner to talk somewhere
curl -I python one liner
I wrote Project Euler 1 in one liner.