How to Post Your Code With Radiant, Harmonious Formatting

You can get your code to format properly by surrounding it in triple backticks and typing the programming language name. This:

[code]```python
enemy = self.findNearestEnemy()
if enemy:
self.attack(enemy)


becomes this:

```python
enemy = self.findNearestEnemy()
if enemy:
    self.attack(enemy)
9 Likes

you can also highlight it and press ctrl+k

1 Like

How do you post a new link not a reply??? :confounded:

you press the little + at the top right of the post

[code]```javascript
while(true) {
var friend = hero.findNearestFriend();
if(friend) {
hero.say("To battle, " + friend.id + “!”);
}
// Now find the nearest enemy and tell them to go away.
var enemy = hero.findNearestEnemy;
if(enemy) {
hero.say(“Go away ,” + enemy.id);
}
}
So… that?

Actually, not quite. However, it has been greatly simplified. All you need do now, is to click on the </> button and post your code between the dots:

image

While True:
    yourCode = "looks like this"