Script for loop issue
If you read the python console start message you will notice that some modules and some variables are builtin or have been imported for our convenience. eg bpy and C = bpy.context. 

PYTHON INTERACTIVE CONSOLE 3.7.3 (default, Apr  3 2019, 19:16:38)  [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]

Command History:     Up/Down Arrow
Cursor:              Left/Right Home/End
Remove:              Backspace/Delete
Execute:             Enter
Autocomplete:        Ctrl-Space
Zoom:                Ctrl +/-, Ctrl-Wheel
Builtin Modules:     bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports: from mathutils import *; from math import *
Convenience Variables: C = bpy.context, D = bpy.data


You need to include your imports in the text editor. To see errors Where does console output go

also consider using for j, name in enumerate(markerlist): to enumerate without using range and length methods. And using scene = bpy.context.scene will use the current (context) scene no matter its name.

import bpy # NEED THIS

scene = bpy.context.scene # &lt; the context scene

markerLIST = ["foo", "bar"]

for j, name in enumerate(markerLIST):
    scene.timeline_markers.new(name, frame=j)


Consider giving the list both the name and frame

import bpy # NEED THIS

scene = bpy.context.scene # &lt; the context scene

markerLIST = [(1, "foo"),
              (20, "bar"),
        ]

for j, name in markerLIST:
    scene.timeline_markers.new(name, frame=j)