numpy, cookbook, python. Let’s see how to concatenate two lists using different methods in Python. Method #1 : Using Naive Method In this method, we traverse the second list … How to shuffle two arrays to the same order. This tutorial shows several examples of how to use this function in practice. Shuffling a list of objects (16) I have a list of objects in Python and I want to shuffle them. Have another way to solve this solution? The shuffle() method takes a sequence (list, string, or tuple) and reorganize the order of the items. Example 1: Zip Two Lists of Equal Length into One List. Next: Write a Python program to generate and print a list of first and last 5 elements where the values are square of numbers between 1 and 30 (both included). I thought I could use the random.shuffle method, but this seems to fail when the list is of objects. If intensites and radius are numpy arrays of your data: bin_width = 0.1 # Depending on how narrow you want your bins def get_avg(rad): average_intensity = intensities[(radius>=rad-bin_width/2.) Here we have used the standard modules itertools and random that comes with Python. Our deck is ordered, so we shuffle it using the function shuffle() in random module. We will get different output each time you run this program as shown in our two outputs. & (radius