3

I have tried everything from using '```python' to indenting myself. The code which I want to upload does get highlighted in grey when I use the above methods but the syntax doesn't get highlighted. Nothing seems to work. Clearly I'm missing out on something that my code is not getting accepted to be asked in Stack Overflow. I keep on getting this error:

Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.

This is my code-

def summer_69(arr):
tot=0
for num in range(0,len(arr)):
    while arr[num]!=6:
        tot+=arr[num]
    num+=1
    while arr[num]!=9:
        tot+=0
    num+=1
    tot+=arr[num]
return tot
summer_69([1, 3, 5])
8
  • 2
    Okay, that is strange as it doesn't work for me either. I can get it to work if I add <!-- language: lang-python --> and a blank line before your code block. Here is what it should look like: i.stack.imgur.com/0rasV.png. What you have tried should work, based on my understanding of how syntax-highlighting works.
    – rene
    Aug 1, 2019 at 6:08
  • Another option is to use lang-python at the first code-fench instead of just python.
    – rene
    Aug 1, 2019 at 6:14
  • 2
    The three ticks and language hint works for me: i.stack.imgur.com/7XYI6.png. I haven't tried submitting it, however. You might need to wait a few seconds for the highlighting kick in. Make sure you test on stack overflow main, meta doesn't have highlighting
    – Rob Mod
    Aug 1, 2019 at 6:16
  • 4
    Also make sure you have an introduction paragraph where you explain what that code is about. Just starting with the code out of nowhere is not going well with the filter that checks the post quality.
    – rene
    Aug 1, 2019 at 6:16
  • 1
    @Rob I took my screenshot on Meta ....
    – rene
    Aug 1, 2019 at 6:17
  • @rene Huh. I could have sworn there was no highlighting here. And the approach I took in my screenshot works on main, but not here
    – Rob Mod
    Aug 1, 2019 at 6:18
  • 1
    @Rob yes, that is strange indeed and inconsistent and confirmed by my testing. I guess that is a bug.
    – rene
    Aug 1, 2019 at 6:19
  • 1
    @rene triple backtick with language works for me on the main site. That's Firefox 68.0.1, if it matters. I do have to wait for a bit for the highlight to kick in, though,
    – VLAZ
    Aug 1, 2019 at 8:24

0

You must log in to answer this question.