I'm going to have to include a lengthy bit of code, but its every necessary part for you to see what I need.

import random

availableCountries = range(20)   # <--- Used at games start, player's countries taken from here
firstTurnsCountries = []         # <--- Player one's country possesion
secondTurnsCountries = []        # <--- Player two's country possesion

pL0 = " "    
pL1 = " "
pL2 = " " # Stores initial blank values for visual display of the continent
pL3 = " "
pL4 = " "       
pL5 = " "       
pL6 = " "       
pL7 = " "       
pL8 = " "       
pL9 = " "       
pL10 = " "      
pL11 = " "      
pL12 = " "
pL13 = " "
pL14 = " "
pL15 = " "
pL16 = " "
pL17 = " "
pL18 = " "
pL19 = " "

playerInitialList = [pL0, pL1, pL2, pL3, pL4, pL5, pL6, pL7, pL8, pL9, pL10, pL11,
                     pL12, pL13, pL14, pL15, pL16, pL17, pL18, pL19]

def continents(): #<--- Visual Display of the 3 continents
    print "         __     ____"
    print "   N.A. |  \   /    ."
    print "         \__|  \ 2  |          ____"
    print "  ____________  |" + str(pL2) + " /  __  Eu  / |  |"
    print " /   |  1  |  \  \|  /13\ ___/  |  |"
    print "/  0 |__" + str(pL1) + "__|_/  |\   ." + str(pL13) + "_// 14  /   |"
    print "|  " + str(pL0) + " |  3 | 4|__|5\      /  " + str(pL14) + "  /    |"
    print " \/ \|__" + str(pL3) + "_|_" + str(pL4) + "__|_" + str(pL5) + "_\ __ |_/|_/| 19 /"
    print " /   |  6  | 7   /  /15\ __/  | " + str(pL19) + " /"
    print "     |__" + str(pL6) + "__|_" + str(pL7) + "_/    ." + str(pL15) + "_/ | 16 |  /"
    print "        \ 8  |          /  _" + str(pL16) + " | |"
    print "         \ " + str(pL8) + " \         /\ / \/\ |"
    print "           \ \        /17|18/  ||"
    print "            _\_      |" + str(pL17) + "_/ ." + str(pL18) + "   \|"
    print "      S.A._/ 9 \__"
    print "         /___" + str(pL9) + "____|"
    print "         |   |    /"
    print "          \ 10|11/"
    print "           |" + str(pL10) + " |" + str(pL11) + "/"
    print "           |__|/"
    print "           |12/"
    print "           |" + str(pL12) + "/"
    print "           |/"

def countryDivider(countryNum):
    while True:
        if not availableCountries: # check if list is spent/empty
            break
        q = random.choice(availableCountries) # pick one available country
        firstTurnsCountries.append(q) # add it to first list
        availableCountries.remove(q) # remove it from the available list
        q = random.choice(availableCountries) # repeat for second list
        secondTurnsCountries.append(q)
        availableCountries.remove(q)
    firstTurnsCountries.sort()
    secondTurnsCountries.sort()
    


player1 = raw_input("What is player 1's Name?")
player2 = raw_input("What is player 2's Name?")
countryDivider(len(availableCountries))
print "\n" + player1 + ", you have been given the following countries:",firstTurnsCountries
print player2 + ", you have been given the following countries:",secondTurnsCountries

playerInitialCounter = 0 # <--- This is the trouble making loop.   
while True:
    if playerInitialCounter in firstTurnsCountries:
        playerInitialList[playerInitialCounter] = player1[0]
    if playerInitialCounter in secondTurnsCountries:
        playerInitialList[playerInitialCounter] = player2[0]
    if playerInitialCounter == 19:
        break
    playerInitialCounter += 1

#    if 0 in firstTurnsCountries:
#        pL0 = player1[0]
#    if 0 in secondTurnsCountries:
#        pL0 = player2[0]
#    if 1 in firstTurnsCountries:
#        pL1 = player1[0]
#    if 1 in secondTurnsCountries:
#        pL1 = player2[0]
#    if 2 in firstTurnsCountries:
#        pL2 = player1[0]
#    if 2 in secondTurnsCountries:
#        pL2 = player2[0]
#    if 3 in firstTurnsCountries:
#        pL3 = player1[0]
#    if 3 in secondTurnsCountries:
#        pL3 = player2[0]
#    if 4 in firstTurnsCountries:
#        pL4 = player1[0]
#    if 4 in secondTurnsCountries:
#        pL4 = player2[0]
#    if 5 in firstTurnsCountries:
#        pL5 = player1[0]
#    if 5 in secondTurnsCountries:
#        pL5 = player2[0]
#    if 6 in firstTurnsCountries:
#        pL6 = player1[0]
#    if 6 in secondTurnsCountries:
#        pL6 = player2[0]
#    if 7 in firstTurnsCountries:
#        pL7 = player1[0]
#    if 7 in secondTurnsCountries:
#        pL7 = player2[0]
#    if 8 in firstTurnsCountries:
#        pL8 = player1[0]
#    if 8 in secondTurnsCountries:
#        pL8 = player2[0]
#    if 9 in firstTurnsCountries:
#        pL9 = player1[0]
#    if 9 in secondTurnsCountries:
#        pL9 = player2[0]
#    if 10 in firstTurnsCountries:
#        pL10 = player1[0]
#    if 10 in secondTurnsCountries:
#        pL10 = player2[0]
#    if 11 in firstTurnsCountries:
#        pL11 = player1[0]
#    if 11 in secondTurnsCountries:
#        pL11 = player2[0]
#    if 12 in firstTurnsCountries:
#        pL12 = player1[0]
#    if 12 in secondTurnsCountries:
#        pL12 = player2[0]
#    if 13 in firstTurnsCountries:
#        pL13 = player1[0]
#    if 13 in secondTurnsCountries:
#        pL13 = player2[0]
#    if 14 in firstTurnsCountries:
#        pL14 = player1[0]
#    if 14 in secondTurnsCountries:
#        pL14 = player2[0]
#    if 15 in firstTurnsCountries:
#        pL15 = player1[0]
#    if 15 in secondTurnsCountries:
#        pL15 = player2[0]
#    if 16 in firstTurnsCountries:
#        pL16 = player1[0]
#    if 16 in secondTurnsCountries:
#        pL16 = player2[0]
#    if 17 in firstTurnsCountries:
#        pL17 = player1[0]
#    if 17 in secondTurnsCountries:
#        pL17 = player2[0]
#    if 18 in firstTurnsCountries:
#        pL18 = player1[0]
#    if 18 in secondTurnsCountries:
#        pL18 = player2[0]
#    if 19 in firstTurnsCountries:
#        pL19 = player1[0]
#    if 19 in secondTurnsCountries:
#        pL19 = player1[0]

continents()

If you uncomment all those lines of code near the bottom it will work flawlessly. But the problem is it's so much code. I tried to cut it down with the loop above it. But it won't work and I don't know why.

It's supposed to change the variables one at a time to the correct first letter depending on who got which countries in their list.

I have looked it over and over, but can't find why it won't work while the large section of code does.

Any and all help would be greatly appreciated.

I played wit it for a little while and came up with these obvious shortcuts:

# changed playerInitialList to pL to save on typing
# changed pL1 etc. to pL[1] etc.
# What do you do if initials of the two players match?

import random

def continents(): #<--- Visual Display of the 3 continents
    """
    list pL contains the inital letters of the players
    the index coincides with the number of the country
    """
    print "         __     ____"
    print "   N.A. |  \   /    ."
    print "         \__|  \ 2  |          ____"
    print "  ____________  |" + pL[2] + " /  __  Eu  / |  |"
    print " /   |  1  |  \  \|  /13\ ___/  |  |"
    print "/  0 |__" + pL[1] + "__|_/  |\   ." + pL[13] + "_// 14  /   |"
    print "|  " + pL[0] + " |  3 | 4|__|5\      /  " + pL[14] + "  /    |"
    print " \/ \|__" + pL[3] + "_|_" + pL[4] + "__|_" + pL[5] + "_\ __ |_/|_/| 19 /"
    print " /   |  6  | 7   /  /15\ __/  | " + pL[19] + " /"
    print "     |__" + pL[6] + "__|_" + pL[7] + "_/    ." + pL[15] + "_/ | 16 |  /"
    print "        \ 8  |          /  _" + pL[16] + " | |"
    print "         \ " + pL[8] + " \         /\ / \/\ |"
    print "           \ \        /17|18/  ||"
    print "            _\_      |" + pL[17] + "_/ ." + pL[18] + "   \|"
    print "      S.A._/ 9 \__"
    print "         /___" + pL[9] + "____|"
    print "         |   |    /"
    print "          \ 10|11/"
    print "           |" + pL[10] + " |" + pL[11] + "/"
    print "           |__|/"
    print "           |12/"
    print "           |" + pL[12] + "/"
    print "           |/"

def countryDivider(countryNum):
    while True:
        if not availableCountries: # check if list is spent/empty
            break
        q = random.choice(availableCountries) # pick one available country
        firstTurnsCountries.append(q) # add it to first list
        availableCountries.remove(q) # remove it from the available list
        q = random.choice(availableCountries) # repeat for second list
        secondTurnsCountries.append(q)
        availableCountries.remove(q)
    firstTurnsCountries.sort()
    secondTurnsCountries.sort()

# create playerInitialList (pL) of 20 spaces
pL = [" "] * 20

availableCountries = range(20)   # <--- Used at games start, player's countries taken from here
firstTurnsCountries = []         # <--- Player one's country possesion
secondTurnsCountries = []        # <--- Player two's country possesion

player1 = raw_input("What is player 1's Name?")
player2 = raw_input("What is player 2's Name?")
countryDivider(len(availableCountries))
print "\n" + player1 + ", you have been given the following countries:",firstTurnsCountries
print player2 + ", you have been given the following countries:",secondTurnsCountries

for x in range(20):
    if x in firstTurnsCountries:
        pL[x] = player1[0]
    elif x in secondTurnsCountries:
        pL[x] = player2[0]
    
continents()

Thanks for your help, you have no idea how much shorter you've made my code, haha.

And yeah, the initials being the same scenario: I was going to work on that next, after I cut that down.

I just thought I'd add in, that I have solved the identicle first initial scenario. What I did was if the first letter of both names are the same, first player gets a capital of that letter, while the second player gets a lower case version. I also tell the users who gets what so they aren't confused.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.