For loop outputting one character per line
Question: I'm writing a quick python script wrapper to query our crashplan server so I
can gather data from multiple sites then convert that to json for a migration
and I've got most of it done. It's probably a bit ugly, but I'm one step away
from getting the data I need to pass on to the json module so I can format the
data I need for reports.

The script should query ldap, get a list of names from a list of sites, then
create a command (which works).

But when printing the list in a for loop it prints out each character, instead
of each name. If I just print the list it prints out each name on a single
line. This obviously munges up the REST call as the username isn't right.

    
    
    '''
    Crashplan query script
    
    Queries the crashplan server using subprocess calls and formats the output
    
    '''
    
    import subprocess
    import json
    
    password = raw_input("What password do you want to use: ")
    
    sitelist = ['US - DC - Washington', 'US - FL - Miami', 'US - GA - Atlanta', 'CA - Toronto']
    cmdsites = ""
    
    
    for each in sitelist:
        cmdsites = cmdsites + '(OfficeLocation={})'.format(each)
    
    ldap_cmd = "ldapsearch -xLLL -S OfficeLocation -h ldap.local.x.com -b cn=users,dc=x,dc=com '(&(!(gidNumber=1088))(|%s))' | grep -w 'uid:' | awk {'print $2'}" % cmdsites
    
    users = subprocess.check_output([ldap_cmd], shell=True)
    
    ##### EVERYTHING WORKS UP TO THIS POINT #####
    
    for each in users:
        #    subprocess.call(['curl -X GET -k -u "admin:'+password+'" "https://crashplan.x.com:4285/api/User?username='+each+'@x.com&incBackupUsage=true&strKey=lastBackup"'], shell=True)   ### THIS COMMAND WORKS IT JUST GETS PASSED THE WRONG USERNAME
        print each           #### THIS PRINTS OUT ONE LETTER PER LINE ####
    
    print type(users)   #### THIS PRINTS OUT ONE NAME PER LINE ####
    


Answer: You get an output as a string which, when iterated, produce _one character per
iteration_.

You should [split it by line
breaks](https://docs.python.org/2/library/stdtypes.html#str.splitlines):

    
    
    for each in users.splitlines():  
        print each
    

