What this error want to say? Can't we use return without function?
Shivlal Sharma
sshivlal9601 at gmail.com
Mon Sep 7 03:40:39 EDT 2020
On Monday, 7 September 2020 at 13:08:04 UTC+5:30, Chris Angelico wrote:
> On Mon, Sep 7, 2020 at 5:36 PM Shivlal Sharma <sshivl... at gmail.com> wrote:
> >
> > On Monday, 7 September 2020 at 12:57:16 UTC+5:30, Python wrote:
> > > Shivlal Sharma wrote:
> > > > 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
> > > What did you expect return out of a function to even mean?
> > I mean that can't we use return keyword outside of the function?
> Well... no. What do you expect it to mean? It's like asking "why can't
> I use 'else' without 'if'?" - there'd need to be some meaning for it.
>
> ChrisA
Ohh, got it. you mean we can't you return without a function, right?
More information about the Python-list
mailing list