Q:

Python: How does this {} formatting work to pull correct data? 

I am using some code by Fraser May for MCP8004 (adc) which I modified for an MCP3002 connected to a Raspberry Pi 1B+ and am now trying to send the data I collect to the sparkfun server, only I'm finding my attempts at grabbing the data returns an empty string.  I'm new to Python, but have some coding experience from school (ME).  
Here's what I have to collect adc data:
def getAdc (channel):
        #check valid channel
        if ((channel>1)or(channel<0)):
            return -1

        # Preform SPI transaction and store returned bits in 'r'
        r = spi.xfer([1, (4+2+channel) << 4, 0])

        #Filter data bits from retruned bits
        adcOut = ((r[0]&3) << 8) + r[1]
        percent = int(round(adcOut/10.24))

        #print out 0-1023 value and percentage
        print("ADC Output: {0:4d} Percentage: {1:3}%".format (adcOut,percent))
        sleep(1)
        return adcOut

Now in my script to send the data to the server I do this (plus modified phant stuff):
adcOut=[]
while True:

            print("collecting data")
            adc = []            #sets adc as a list

            for i in range(2):
                    getAdc(i)
                    adc.append(adcOut)
                    print adcOut
            print("ADC data collected!") 

I thought I could just call adc[0] or adc[1] to get the data I want, which is displayed in the getAdc function, but apparently not, I'm getting an empty list ([]). 
I think my problem is in what happens in getAdc, where {0:4d} and {1:3} are used, but I'm not sure what those do.  Can anyone help break that part down?  So far all I've been able to find are documents explaining what d and % do, but they don't make sense to me as applied here. 
Thanks in advance! 
*note: adcOut is declared global before my getAdc script. 

A:

Option 1:
You need to indicate that you want to modify the global adcOut variable, not just read its value.  Modify getAdc() as follows by adding a global adcOut to the function:
def getAdc (channel):
    global adcOut  # <-- this line is added
    #check valid channel
    if ((channel>1)or(channel<0)):
        return -1

    # Preform SPI transaction and store returned bits in 'r'
    r = spi.xfer([1, (4+2+channel) << 4, 0])

    #Filter data bits from retruned bits
    adcOut = ((r[0]&3) << 8) + r[1]
    percent = int(round(adcOut/10.24))

    #print out 0-1023 value and percentage
    print("ADC Output: {0:4d} Percentage: {1:3}%".format (adcOut,percent))
    sleep(1)

Option 2:
Alternatively, you can return adcOut by adding return adcOut to the end of the function and changing the code at your invocation point as follows:
adcOut=[]
while True:

        print("collecting data")
        adc = []            #sets adc as a list

        for i in range(2):
                adcOut = getAdc(i)  # <-- note this changed line
                adc.append(adcOut)
                print adcOut
        print("ADC data collected!") 

The better option, IMO, is #2 - return adcOut rather than use global variables.