Got error

Got error.

#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#define DHTPIN 8
LiquidCrystal_I2C lcd (0x3F, 16,2);
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);




void setup() {
  dht.begin();
  lcd.begin();

}

void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  if (isnan(t) || isnan(h))
  lcd.setCursor(0, 0);
  lcd.print("Failed to read from DHT");
}else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Humidity: ");
    lcd.print(h);
    lcd.print("%");
    lcd.setCursor(0, 1);
    lcd.print("Temp: ");
    lcd.print(t);
    lcd.print("c");
}

Arduino: 1.8.7 (Windows 10), Board: “Arduino/Genuino Uno”

Vejr_station:24:2: error: expected unqualified-id before ‘else’

}else {

^

Multiple libraries were found for “LiquidCrystal_I2C.h”
Used: H:\Arduino\libraries\LiquidCrystal_I2C
Not used: C:\Users\Henrik\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master
exit status 1
expected unqualified-id before ‘else’

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

if (isnan(t) || isnan(h))Needs more {

If you auto-format the sketch you can see more clearly that you forgot to put a '{' before the contents of your 'if' statement. That makes the '}' just before 'else' the end of the loop() function body (not the end of the 'if' body). The compiler is upset that you have an 'else' keyword outside of a function.

void loop()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  if (isnan(t) || isnan(h))
    lcd.setCursor(0, 0);
  lcd.print("Failed to read from DHT");
} else
{