I am new to python and I am trying to create a solution for a statement. There are two teams playing a game against each other. Each team has 11 players, so there are total 22 players. Out of 22 players need to select only 11 players. Now out of selected 11 players one can be captain and one can be vice-captain. We can read players name from excel. Solution is to input all the 22 players name and display all the teams (11 players) with captain and vice-captain. Here I am able to generate the random team out of 22 players but above mentioned constraints are getting matched. import random def get_random_player(players): return players.pop(random.randrange(len(players))) team_1 = [] players = ["Rahul","Virat","Sachin","King"] //22 players for x in range(len(players) // 2): team_1.append(get_random_player(players)) print(team_1) Example : Team 1 : Team1_Palyer1 Team1_Palyer2 Team1_Palyer3 Team1_Palyer4 Team1_Palyer5 Team1_Palyer6 Team1_Palyer7 Team1_Palyer8 Team1_Palyer9 Team1_Palyer10 Team1_Palyer11 Team 2 : Team2_Palyer1 Team2_Palyer2 Team2_Palyer3 Team2_Palyer4 Team2_Palyer5 Team2_Palyer6 Team2_Palyer7 Team2_Palyer8 Team2_Palyer9 Team2_Palyer10 Team2_Palyer11 Output : Team1_Palyer1 Team2_Palyer1 Team1_Palyer3(c) Team2_Palyer5 Team1_Palyer5 Team2_Palyer6 Team2_Palyer7(vc) Team1_Palyer4 Team2_Palyer9 Team2_Palyer10 Team1_Palyer10 Here we have 5 plyers from Team 1 and 6 players from Team 2 Made Team1_Palyer3 as captain and Team2_Palyer7 as vice-captain. Need to display all the teams which can be created. Continue reading...