Printing the first value in an array instead of just the first letter? (Python)
Question: I have used Python to append data from an SQLite3 database to an array. Now
that I have an array, I am trying to print the appended data in a format along
the lines of:

    
    
    print "Team: " + new_array[0][0] + " Score: " + new_array[0][1] + " Overall: " + new_array[0][2]
    

The code I have already would be okay for this. However, I am trying to create
a loop using a counter that would print all of the data from the array in the
above format.

The problem is that when I try to create a for loop and print the first value
in the array, only the first letter of the value is printed. For example:

    
    
        print new_array[0]
    

... would print:

    
    
        team_6
        team_3
        team_5
        team_1
        team_2
        team_4
    

... and...

    
    
        print new_array[0][0]
    

... would print:

    
    
        t
        t
        t
        t
        t
        t
    

This is what I have so far: import sqlite3

    
    
        new_array = []
    
        conn = sqlite3.connect('league.db')
        c = conn.cursor()
    
        game = c.execute("SELECT Team,Score,Overall FROM League ORDER BY Overall DESC")
        for items in game:
            new_array.append(items)
    
        print new_array[0][0]
    

The code above will print out 'team_6' as it should. However, the problem of
printing 't's only occurs when I create a for loop.

Your help would be greatly appreciated. Thanks.


Answer: Try this to get expected output

    
    
    for items in game.fetchall():
        print items[0] # should be `team6` and so on
    

If you want to put in array.Do like this

    
    
    for items in game.fetchall():
        new_array.append(items)
    
    >>>new_array[0][0]
    'team6'
    

