input: Write a python function to train a RandomForestClassifier on a dataset and make predictions on new data.
  assert train_and_predict(df, new_data) == expected_prediction
  assert train_and_predict(df2, new_data2) == expected_prediction2
  assert train_and_predict(df3, new_data3) == expected_prediction3
output: def train_and_predict(df, new_data):
      from sklearn.ensemble import RandomForestClassifier
      from sklearn.model_selection import train_test_split
      from sklearn.preprocessing import LabelEncoder
      
      # Assuming the last column is the target
      X = df.iloc[:, :-1]
      y = df.iloc[:, -1]
      
      # Encode target if it's categorical
      if y.dtype == 'object':
          le = LabelEncoder()
          y = le.fit_transform(y)
      
      # Train-test split
      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
      
      # Initialize and train the model
      model = RandomForestClassifier(random_state=42)
      model.fit(X_train, y_train)
      
      # Predict on new data
      predictions = model.predict(new_data)
      
      return predictions.tolist()