Python Forum
len() function, numbers doesn't work with Geany Editor
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
len() function, numbers doesn't work with Geany Editor
#1
HI all,


i am a beginner and study python via Geany.
I encounter the below issues.
when i input the code in Geany and run the program,the geany show nothing
E.g
name=["Karen","John",May","Philips")
len(name)
or
15/3

however, if i run the Python 3.8 directly
the same code, it show

name=["Karen","John",May","Philips")
len(name)
>>>4
15/3
>>>5

please help me. Thx
Reply
#2
It's not clear what your goal is.
Reply
#3
(May-08-2020, 02:42 AM)Penguin827 Wrote: HI all,


i am a beginner and study python via Geany.
I encounter the below issues.
when i input the code in Geany and run the program,the geany show nothing
E.g

name=["Karen","John","May","Philips")
len(name)
15/3
But if i use the print function, the output (number) can be showed

name=["Karen","John","May","Philips")
len(name)
print(len(name))
4
print(15/3)
5
besides, if i run the Python 3.8 directly
the same code, it can show the number

name=["Karen","John","May","Philips")
len(name)
4
15/3
5
please help me. i cant run the outcome which include numbers in Geany. Thx
Reply
#4
Please read, https://python-forum.io/Thread-How-to-Ex...ython-code
In short, you can execute python code in python shell (i.e. python interactive mode, that is when you have >>>) or save the code in .py file (you can use any IDE or text editor) and execute that file from command line. This is how would you normally write and execute code. python shell normally is used only for some ad-hoc experiment or demo.

When you run in python shell, each line is evaluated and result is displayed immediately. That is why you "see" result.
When you write code in .py file, you need to print in order to get visual output
e.g.
names = ["Karen","John",May","Philips")
print(len(names))
names_length = len(names)
print(names_length)
print(15/3)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 233 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  Why doesn't calling a parent constructor work with arbitrary keyword arguments? PurposefulCoder 4 870 Jun-24-2023, 02:14 PM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,681 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  color code doesn't work harryvl 1 842 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  I dont know why my function won't work? MehHz2526 3 1,150 Nov-28-2022, 09:32 PM
Last Post: deanhystad
  client.get_all_tickers() Doesn't work gerald 2 1,664 Jun-16-2022, 07:59 AM
Last Post: gerald
  pip doesn't work after Python upgrade Pavel_47 10 4,056 May-30-2022, 03:31 PM
Last Post: bowlofred
  Music Notation editor; how to build the editor? direction to go? philipbergwerf 1 1,650 Jan-01-2022, 04:56 PM
Last Post: Larz60+
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 1,930 Dec-18-2021, 02:38 AM
Last Post: knight2000
  Class Method to Calculate Age Doesn't Work gdbengo 1 1,660 Oct-30-2021, 11:20 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020