Hello I try to find the top 10 albums in the chinook database 18
Don't print row[3], print something else. Is there a way to get a loop counter?
i try to create a counter loop
Clearwater Revival tracks 18
# Print the results
for n, (albumid, album, artist, tracks) in enumerate(result, start=1):
print(f'{n}. {album} by {artist} - tracks: {tracks}')
Note, code not tested
I have found the solution
result = cur.fetchall()
count = 0
# Print the results
for row in result:
count += 1
print(count, row[1], 'by', row[2], '-', row[3])
Last question eedence Clearwater Revival 18[/output]
Formatting the print statement. While you are looking up how to format print commands in python you should also read about the enumerate command.
Thanks i try the Formatting the print statement but can you please give a tip how i can do it
(May-10-2023, 02:02 PM)Kessie1971 Wrote: [ -> ]Thanks i try the Formatting the print statement but can you please give a tip how i can do it
Google "python print formatting"?
couldn't you just replace rows 26 and 27 from post 1 with:
for n, row in enumerate(result):
print(f"row {n}: {row[n]}")