How to sort names by their scores from rolling dice
<p>I'm working on a program that generates three different integers and assigns them to individual values so that It can be decided to goes first, second, and third.  In this case, I'm assuming three different players, each one rolls a "ten-sided die".  The highest should get the first turn, second highest should go second, third should go last.  Everything seems to be rolling okay, but now that I have my values I can't figure out how to arrange them so that I can start having the players take turns playing.  I would appreciate any input.</p>

<p>Here is the code I've put together so far:</p>

<pre><code>import sys
import os
import random
import time

os.system('clear')
print ('Welcome!  Please type Player 1\'s name!: ')
playerOne = input()
print ('Okay!  Please type Player 2\'s name!: ')
playerTwo = input()
print ('Fantastic!  Finally, please type Player 3\'s name!: ')
playerThree = input()
os.system('clear')
print()
time.sleep(2)

def startFightRoll():
    playerOneRoll = random.randint(1,10)
    time.sleep(.5)
    print('Okay, let\'s roll a ten-sided die to see who gets to go first!')
    print()
    time.sleep(2)
    print ('&lt;Ten-sided dice roll&gt; ')
    print ('---------------------------------')
    print (playerOne + ' rolls ' + str(playerOneRoll))
    print()
    print()
    playerTwoRoll = random.randint(1,10)
    time.sleep(2)
    print ('&lt;Ten-sided dice roll&gt; ')
    print ('---------------------------------')
    print (playerTwo + ' rolls ' + str(playerTwoRoll))
    print()
    print()
    playerThreeRoll = random.randint(1,10)
    time.sleep(2)
    print ('&lt;Ten-sided dice roll&gt; ')
    print ('---------------------------------')
    print (playerThree + ' rolls ' + str(playerThreeRoll))

startFightRoll()
</code></pre>

<p>In response to threads below;</p>

<p>Okay, so I'm new at this so please forgive my code - it's not efficient and I'm still getting used to things. I've added some parts to it to address 1) player entering nothing in the name field, and 2) ties being generated in the dice roll. I've also created a list of the dice rolls in descending order, but now I need to find a way to assocate the rolls back to the user who generated it. Any pointers on how to do this properly is deeply appreciated;</p>

<pre><code>import sys
import os
import random
import time

os.system('clear')


def playerOneName():
    global playerOne
    playerOne = input()
    if len(playerOne) &lt; 1:
        print('Please enter your name, Player 1!')
        playerOneName()

def playerTwoName():
    global playerTwo
    playerTwo = input()
    if len(playerTwo) &lt; 1:
        print('Please enter your name, Player 2!')
        playerTwoName()

def playerThreeName():
    global playerThree
    playerThree = input()
    if len(playerThree) &lt; 1:
        print('Please enter your name, Player 3!')
        playerThreeName()

os.system('clear')
print()
time.sleep(2)
def startFightRoll():
    global playerOneRoll
    global playerTwoRoll
    global playerThreeRoll
    playerOneRoll = random.randint(1,10)
    time.sleep(.5)
    print('Okay, let\'s roll a ten-sided die to see who gets to go first!')
    print()
    time.sleep(2)
    print ('&lt;Ten-sided dice roll&gt; ')
    print ('---------------------------------')
    print (playerOne + ' rolls ' + str(playerOneRoll))
    print()
    print()
    playerTwoRoll = random.randint(1,10)
    time.sleep(2)
    print ('&lt;Ten-sided dice roll&gt; ')
    print ('---------------------------------')
    print (playerTwo + ' rolls ' + str(playerTwoRoll))
    print()
    print()
    playerThreeRoll = random.randint(1,10)
    time.sleep(2)
    print ('&lt;Ten-sided dice roll&gt; ')
    print ('---------------------------------')
    print (playerThree + ' rolls ' + str(playerThreeRoll))
    if playerOneRoll == playerTwoRoll:
        print ('There\'s a tie, rolling again!')
        time.sleep(3)
        os.system('clear')
        startFightRoll()
    if playerOneRoll == playerThreeRoll:
        print ('There\'s a tie, rolling again!')
        time.sleep(3)
        os.system('clear')
        startFightRoll()
    if playerTwoRoll == playerThreeRoll:
        print ('There\'s a tie, rolling again!')
        os.system('clear')
        time.sleep(3)
        startFightRoll()    

    O = [playerOneRoll, playerTwoRoll, playerThreeRoll]
    O = sorted(O, reverse = True)
    print (O)

print ('Welcome!  Please type Player 1\'s name!: ')
playerOneName()
print ('Okay!  Please type Player 2\'s name!: ')
playerTwoName()
print ('Fantastic!  Finally, please type Player 3\'s name!: ')
playerThreeName()
os.system('clear')
startFightRoll()
</code></pre>
