Here is an example code to create 20 teams of Dream11 in Python:
import random players = ["Player1", "Player2", "Player3",
"Player4","Player5", "Player6", "Player7",
"Player8","Player9", "Player10", "Player11"]
teams = [] for i in range(20): team = [] for j in range(11): player = random.choice(players) team.append(player) players.remove(player) teams.append(team) for i, team in enumerate(teams): print(f"Team {i+1}: {', '.join(team)}")
Explanation:
- We first create a list of players that we will use to create the teams.
- We then create an empty list called
teams
which we will populate with the 20 teams of Dream11. - We use a nested
for
loop to create each team. The outer loop iterates 20 times to create 20 teams, and the inner loop iterates 11 times to select 11 players for each team. - We use the
random.choice()
function to select a random player from theplayers
list and add it to the current team. We also remove the selected player from theplayers
list to ensure that each player is selected only once. - Finally, we print the 20 teams with their respective players using a formatted string and the
join()
function to convert the list of players to a string separated by commas.
Note: In the above code, you can replace the list of players with the actual list of players for the Dream11 game.
Click here for C code :https://pnktech.blogspot.com/2023/02/create-20-different-teams-of-dream11.html
Social Plugin