import machine
import utime
import dht
# Use machine.Pin(15)
sensor = dht.DHT22 (machine.Pin(5))
# Use 'True' (uppercase T)
while True:
try:
sensor. measure()
temp = sensor.temperature()
hum = sensor.humidity()
# Use .format () or f-string with correct syntax and specifiers (.1f)
print ("Temperature: (:.1f)°C | Humidity: {:.1f)%". format(temp, hum))
except OSError as e:
# Correct print function and syntax
print("Error reading sensor (OSError):", e)
utime.sleep(5)