Jump to content
Sign in to follow this  
Alan Woodwell

Code not calling

Recommended Posts

Hi, is there any reason why this code is not calling?

I am sure I copied it right.



def fib2(n): # return Fibonacci series up to n

"""Return a list containing the Fibonacci series up to n."""

result = []

a, b = 0, 1

while a < n:

result.append(a) # see below

a, b = b, a+b

return result

f100 = fib2(100)



If I add

print (f100)

I get a print out but I thought this calls the list without the need to print?

Edited by Alan Woodwell

Share this post

Link to post

Hi Alan

Where are you running your script?

In the script editor for vectorworks?

or the Python IDE?

If in the script editor, the print function displays only if an error has occured and you inspect the error.

I normally use the vs.Message() or vs.AlrtDialog() calls to query variables in code. both need whatever variable to be of string type.

in this case it would be:




If in the IDE: I'm running your script from the Python 3.3.3 Shell (Windows 10) and both methods work. ie calling f100 and also print(f100) shows the list of the Fibonacci sequence

Edited by twk

Share this post

Link to post

Hi, running it on my iPad.

And using Python 2.7 app

I am still learning how to code and understanding the indenting etc, so I am on a steep learning curve.

I am doing purely Python at present.


Edited by Alan Woodwell

Share this post

Link to post

ahh ok,

well if its running from a module(.py file, in your case 4.6-04.py), I believe you have to call the 'print' function to display it in the python command prompt.

If you're entering commands directly in the prompt, calling a variable like f100 will display its value on the next line, regardless of calling print or not.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.