Problem with print in a for loop

With this code I am trying to make a line break after every row,

query = “SELECT * FROM sensorlog”
c.execute(query)
for row in c:
print(“%s\n” % ("Temperature ",row[1], "C Humitidy ", row[2], "% Date ", row[3]))

but I get this errormessage

TypeError: not all arguments converted during string formatting

Can someone help me with this problem?

This format string expects one string as an argument.

You are passing 6 arguments.

Consider using f’strings’.

print(f’Temperature {row[1]} C Humitidy {row[2]} Date {row[3]}’)
1 Like

Now it displays without errrors.

But wan’t to get this output on the screen

Is it possible?

print(f’Temperature {row[1]} C | Humitidy {row[2]} | Date {row[3]}’)

should do it.

Personally, I’d prefer:

print(f’Temperature {row[1]} C | Humidity {row[2]} | Date {row[3]}’)

Ok, I take it that you’re not referring to the IDE terminal but the actual screen of your computer - since you showed the output results to the test script that you provided. Is this about right?

If so, here is a link that provides a test script for you to follow - scroll towards the bottom of the page. You’ll see the answer of interest with a green checkmark.