Reputation: 119
I am working on a program that generates a single elimination tournament. so far my code looks like this ( i have just started)
amount = int(raw_input("How many teams are playing in this tournament? "))
teams = []
i = 0
while i<amount:
teams.append(raw_input("please enter team name: "))
i= i+1
now i am stuck. I want to randomly pick 2 numbers that will select the teams facing eachother. the numbers cannot repeat at all, and have to range from 1 to "amount". What is the most efficient way to do this?
Upvotes: 3
Views: 1598
Reputation: 2445
I'm not entirely sure what you are asking however to chose random number you can use for example
random.randint(1,10)
this will give you a random number between 1 to 10
Note: you need to import the random module
import random
Upvotes: 0
Reputation: 1011
team1 = random.choice(teams)
teams.remove(team1)
team2 = random.choice(teams)
I think that should work.
Upvotes: 2