Give an example of shuffle() method?

Posted by Editorial Staff | Updated on

Python shuffle() is a builtin function which shuffles the given string or an array.  It randomizes the items in the array. This method is present in the random module. So, we need to import it and then we can call the function. It shuffles elements each time when the function calls and produces different output.


Program Output:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers