Ask coding questions

← Back to all posts
How to reformat and indent Python code
h
PaoloAmoroso (69)

In a Python REPL, suppose I edit some code in a file and break the canonical indentation. Is there an editor command to reformat and indent the code? I've the command palette but haven't found anything relevant.

Answered by malvoliothegood (147) [earned 5 cycles]
View Answer
Commentshotnewtop
malvoliothegood (147)

It can be tricky. You could try copying and pasting your code into an online formatter. E.g. https://www.tutorialspoint.com/online_python_formatter.htm

PaoloAmoroso (69)

@malvoliothegood So it looks like Repl.it doesn't provide a reformat option. Thanks anyway.