input: Write a python function to train a linear regression model on a dataset and return its accuracy.
  assert train_and_evaluate_linear_regression('data.csv') > 0
  assert isinstance(train_and_evaluate_linear_regression('data.csv'), float)
output: def train_and_evaluate_linear_regression(filename):
      import pandas as pd
      from sklearn.model_selection import train_test_split
      from sklearn.linear_model import LinearRegression
      from sklearn.metrics import r2_score
  
      # Load dataset
      data = pd.read_csv(filename)
      
      # Assuming the last column is the target variable
      X = data.iloc[:, :-1].values
      y = data.iloc[:, -1].values
      
      # Split the data into training and testing sets
      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
      
      # Train the linear regression model
      model = LinearRegression()
      model.fit(X_train, y_train)
      
      # Make predictions on the test set
      y_pred = model.predict(X_test)
      
      # Calculate the accuracy of the model using R^2 score
      accuracy = r2_score(y_test, y_pred)
      
      return accuracy