What this error want to say? Can't we use return without function?
Schachner, Joseph
Joseph.Schachner at Teledyne.com
Tue Sep 8 14:45:47 EDT 2020
I see. You didn't declare a function, it's just a python script. So you don't need a return in that situation, the script just ends when there are no more lines.
By the way: you certainly don't want to return or quit BEFORE you print(nice). But the fix here is simply to delete "return coun". Then your script will run.
--- Joseph S.
-----Original Message-----
From: Shivlal Sharma <sshivlal9601 at gmail.com>
Sent: Monday, September 7, 2020 3:09 AM
To: python-list at python.org
Subject: What this error want to say? Can't we use return without function?
N = int(input("enter a positive integer:")) coun = 1 while (N > 0):
coun = coun * N
N = N - 1
return coun
nice = ntime(N)
print(nice)
error: return outside of the function
More information about the Python-list
mailing list