Python Forum
Built in Functions not working - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Built in Functions not working (/thread-4178.html)



Built in Functions not working - mhoneycutt83 - Jul-27-2017

Basic built in functions like len(),str(),int() and float() do not work in a text.py file but do in IDLE. Does anyone know why and how to fix this. I'm kind of stuck on this until I can move on to the next task.

len("python")
str(100)
int("1")
float(100)

int("110")
int(20.54)

float("16.4")
float(99)

Results in IDLE:

Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
RESTART: C:\Users\mhoneycutt.EMSTEC\AppData\Local\Programs\Python\Python36\test1.py
>>>


RE: Built in Functions not working - sparkz_alot - Jul-27-2017

Please be more descriptive of the problem.

If what you posted is the contents of text.py, you aren't printing anything. You would need something like

print(int("1"))
as an entry


RE: Built in Functions not working - DeaD_EyE - Jul-27-2017

There is a difference between typing code in the interactive repl (IDLE) or executing a script.
The abbreviation repl stands for Read-Evaluate-Print-Loop.

When entering the code into IDLE, you get always the last Output and additional output which is printed via the print function to stdout.

Executing a Python program does it not. There you have explicit to print the output. Your assumption that a script does the same, is not logical. If a program does this, it's very verbose and useless at the end.


RE: Built in Functions not working - mhoneycutt83 - Jul-27-2017

That makes complete sense. I can't believe I didn't realize this. Thanks for the reply.


RE: Built in Functions not working - DeaD_EyE - Jul-28-2017

No problem. Beginners can run into it. Sometimes we forget how it was as we started with programming.