Sublime Forum

NEW here : len() function not displaying the lenght of the list but the program runs

#1

So I tried using a len function to display the length of a list. It just doesnt display the number unless i print it.

Is there something I need to do?

Im sorry I am new to this

0 Likes

#2

This is expected behaviour.

Outside of specific environments such as a REPL (Read Evaluate Print Loop) that prompt you for a line of code at a time, executing it and printing the result, programs only do what you tell them to.

As such, if you want to see output such as the value of variables or the result of function calls, you need to tell the program to print it.

0 Likes

#3

Is there a way for me to add a REPL intepreter inside sublime text?

0 Likes

#4

The SublimeREPL package does something like this, but it’s rather old, unmaintained and be a bit difficult to use.

If the idea is that you want to just execute ad-hoc Python code inside of Sublime, you can set that up by using the Terminus package, though. You just need to construct a build system that executes python -i.

0 Likes

#5

thanks alot for the help, makes things easier now :smiley:

0 Likes