I'm writing a program and I need to scramble the letters of string
s from a list
in python. For instance I have a list
of string
s like:
l = ['foo', 'biology', 'sequence']
And I want something like this:
l = ['ofo', 'lbyoogil', 'qceeenus']
What is the best way to do it?
Thanks for your help!
Like those before me, I'd use
random.shuffle()
:See also:
map()
Python has batteries included..
A list comprehension is an easy way to create a new list:
You can use random.shuffle:
From this you can build up a function to do what you want.