What this error want to say? Can't we use return without function?

2020-09-07 Thread Shivlal Sharma
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 -- https://mail.python.org/mailman/listinfo/python-list

Re: What this error want to say? Can't we use return without function?

2020-09-07 Thread Shivlal Sharma
On Monday, 7 September 2020 at 13:10:57 UTC+5:30, Shivlal Sharma wrote: > 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 wrote: > > > > > > On Monday, 7 September 2020 at 12:5

Re: What this error want to say? Can't we use return without function?

2020-09-07 Thread Shivlal Sharma
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 wrote: > > > > On Monday, 7 September 2020 at 12:57:16 UTC+5:30, Python wrote: > > > Shivlal Sharma wrote: > > > > N = int(input("e

Re: What this error want to say? Can't we use return without function?

2020-09-07 Thread Shivlal Sharma
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 = ntim

Error in lambda function..!

2020-08-29 Thread Shivlal Sharma
from functools import* nums = [1, 2, 3, 4, 5, 6, 7, 8, 9] add = reduce(lambda a : a + 1, nums) print(add) error: - TypeError Traceback (most recent call last) in () 1 from functools import* 2 nums = [1, 2, 3, 4, 5, 6, 7, 8, 9] > 3 add = reduce(lambd

Re: Didn't understand the output of the following Python 3 code with reduce function?

2020-08-29 Thread Shivlal Sharma
On Saturday, 29 August 2020 at 02:47:56 UTC+5:30, Ben Bacarisse wrote: Thanks you all, I was really confused in this code. > Shivlal Sharma writes: > > > I have seen this code on one of competative programming site but I > > didn't get it, Why output is 9? > &g

Didn't understand the output of the following Python 3 code with reduce function?

2020-08-28 Thread Shivlal Sharma
I have seen this code on one of competative programming site but I didn't get it, Why output is 9? from functools import * def ADDS(a,b): return a+1 nums = [1, 2, 3, 4, 5, 6, 7, 8, 9] add = reduce(ADDS, nums) print(add) output: 9 -- https://mail.python.org/mailman/listinfo/python-list