Using backticks to format your code

Just in case someone curious end up here and is wondering what is the backticks thing he is talking about, here is the trick:

Whenever you would like to paste code, since this forum supports Markdown syntax you can use three backticks before and after your code block like so:

```
def my_func(x):
my_var = 0
if x > my_var:
sum = my_var + x
else:
print “Odelay!”
return sum
```

and it will retain proper indentation and even have nifty syntax highlighting:

def my_func(x):
    my_var = 0
    if x > my_var:
      sum = my_var + x
    else:
      print "Odelay!"
    return sum

The key to get a backtick character is highlighted in blue on this US keyboard layout:

12 Likes