With this code I am trying to make a line break after every row,but I get this errormessageCode:
query = “SELECT * FROM sensorlog”c.execute(query)for row in c:print(“%s\n” % ("Temperature ",row[1], "C Humitidy ", row[2], "% Date ", row[3]))
TypeError: not all arguments converted during string formattingCode:
Can someone help me with this problem?
No indentation before print puts it outside the for loop. But that's not what's causing the error. Your use of % substitution is incorrect.
You should have one string to the left of the % with multiple occurrences of %s in it indicating where the values go:
Code:
print(“Temperature %sC Humitidy %s Date %s” % (row[1], row[2], row[3]))Statistics: Posted by thagrol — Mon Dec 15, 2025 12:46 pm