The error is very clear, it is expected that there is an indentation block between the second line and the first line. Python identifies the blocks of code through the different levels of indentation and not through specific symbology such as keys or reserved words ( Begin
, End
, etc) as I suppose you already know.
As I mentioned before, it is important that you add the correctly formatted code because an error of indentation can be due to several reasons, including mixing tabs and spaces. This can only be detected if you copy and format the code exactly as you have it in your editor.
Since your code is simple and following the recommendations of PEP-8 on indentation (use of 4 spaces between levels), your code should be (for lack of a better context):
def plot_feature_importances_cancer(model):
n_features = cancer.data.shape[1]
plt.barh(range(n_features), model.feature_importances_, align='center')
plt.yticks(np.arange(n_features), cancer.feature_names)
plt.xlabel("Feature importance")
plt.ylabel("Feature")
plot_feature_importances_cancer(tree)