Aug-01-2023, 03:11 PM
(This post was last modified: Aug-01-2023, 03:55 PM by Gribouillis.)
I am following a Python tutorial and have created the following module(from the tutorial) in Notepad under Windows 11:
What am I missing here?
def fib(n): # write Fibonacci series up to n a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b print() def fib2(n): # return Fibonacci series up to n result = [] a, b = 0, 1 while a < n: result.append(a) a, b = b, a+b return resultI have saved the module as fibo.py. When I attempt to import the module(import fibo), Python returns the error:
Error:SyntaxError: source code string cannot contain null bytes
Now when I save the module as kw.py or kirk.py, the import works and calls to the functions in the module also work. What am I missing here?
Gribouillis write Aug-01-2023, 03:54 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.