[Tutor] How default arg of function works

2018-06-14 Thread Deepak Dixit
I am learning python and working with function. Here is my test program :- program.py def test1(nums=[]): return nums def test2(nums=[]): nums.append(len(nums)); return nums print "Calling test1" print '=' * 40 print 'test1()', test1

Re: [Tutor] How default arg of function works

2018-06-14 Thread Deepak Dixit
other topics , is it only possible after more and more practice. Any suggestions from your side will be really helpful for me. On Thu, Jun 14, 2018, 1:00 PM Alan Gauld via Tutor wrote: > On 14/06/18 08:04, Deepak Dixit wrote: > > > def test2(nums=[]): > > nu

Re: [Tutor] How default arg of function works

2018-06-14 Thread Deepak Dixit
Thanks a lot for this information. On Thu, Jun 14, 2018, 4:28 PM Alan Gauld via Tutor wrote: > On 14/06/18 08:40, Deepak Dixit wrote: > > You mean that for default args and passed args of mutable type, python > uses > > different object and same reference will be used for

Re: [Tutor] help please

2018-10-10 Thread Deepak Dixit
On Wed, Oct 10, 2018, 12:37 PM Michael Schmitt wrote: > To whom it may concern: > > > I am trying to teach myself Python and ran into a problem. This is my code > > > # name of rivers and country > > rivers = {'nile' : 'egypt', 'ohio' : 'US', 'rhine' : 'germany' } > > # prints river name > for ri