passcot
passcot

Reputation: 199

Code not indenting properly. Is there a solution?

It seems that the python code in R reticulate is not indenting automatically. E.g. when I write

if x < 0:
  print("negative")
  else:
    print("positive")

the third line should move automatically at the same level of if but, it actually does not and I get the message IndentationError: unexpected indent (<string>, line 1)

Is this bug or can it be corrected?

Upvotes: 1

Views: 960

Answers (1)

Gowachin
Gowachin

Reputation: 1270

This can be solved by correcting the indentation of you code, following Python rules :

You need to unindent the else so it's indentation match the if ones. Rstudio don't indent correctly for Python to this day.

if x < 0:
  print("negative")
else:
  print("positive")

Upvotes: 1

Related Questions