**solved** per accepted answer. I would also encourage readers to read @Nathan Tuggy's answer, which has some related details that may help you understand the issue more quickly

---

Question
========

I have some Python code I'm trying to format, but only *part* of the block comes out formatted. I've pasted the problem formatting below; originally from <https://stackoverflow.com/a/41812246>

I've tried:

* `Ctrl` + `K` indent the whole block
* (Should be the same) but manually 4-space indent the block
* Use triple back-tics
* Ensure new-lines are between all formatting changes
* < !-- language: lang-python -- >

All have the same result, which is that only part of the code block is rendered as code, and other parts are just rendered as text.

`xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xx below this should be **ALL** code xx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`

@DavidPosthill - I don't see how the subsequent code block is preceded by a list item here.

```
import sys, time, msvcrt

def readInput( caption, default, timeout = 5):

```
start_time = time.time()
sys.stdout.write('%s(%s):'%(caption, default))
sys.stdout.flush()
input = ''
while True:
    if msvcrt.kbhit():
        byte_arr = msvcrt.getche()
        if ord(byte_arr) == 13: # enter_key
            break
        elif ord(byte_arr) >= 32: #space_char
            input += "".join(map(chr,byte_arr))
    if len(input) == 0 and (time.time() - start_time) > timeout:
        print("timing out, using default value.")
        break

print('')  # needed to move to next line
if len(input) > 0:
    return input
else:
    return default

```

And some examples of usage
==========================

ans = readInput('Please type a name', 'john')
print( 'The name is %s' % ans)
ans = readInput('Please enter a number', 10 )
print( 'The number is %s' % ans)
```

@DavidPosthill - or how the list-item explanation applies to the code stoping, mid-block, and returning to paragraph formatting