This is because your program calculates the length of the string with len, but doesn’t do anything to display it.
Python is capable of:
- Running the program you provide it from an input file, then exiting
- Running the program you provide it from an input file, then entering interactive mode to allow you to continue entering statements
- Running directly in interactive mode for you to enter statements
When running interactively, it acts as a REPL (Read-Evaluate-Print-Loop), where you enter a statement, it executes it, then displays the result and waits for more input.
Possibly the tutorial/book that you’re using to learn Python is showing examples of code as executed in the REPL mode.
Sublime uses the first method above; it tells the Python interpreter to run your program and then exit. In this mode the interpreter only does exactly what you told it to. As such, since your program doesn’t display the result of the operation, it appears as if nothing happens.
You can modify your program to print the output:
a = "This is my string"
print(len(a))
In general, Sublime can’t run in the other two modes, because although the output of the interpreter is connected to the output panel so you can see what’s happening, it doesn’t connect the input of the interpreter to anything; thus if you run a program that waits for user input, your program will block forever because they’re no way to pass it the input.
You can get around that by using a REPL plugin for Sublime, which gives you the interactive mode you may expect. One such example is SublimeREPL, which seems quite popular although I have no experience with it personally.