L=[2,1]
L[0],L[L[0]-1]=L[L[0]-1],L[0]
The L doesn't change. Can someone provide me the detail procedure of this
expression?
--
https://mail.python.org/mailman/listinfo/python-list
c="abcdefghijk"
len=len(c)
n is a int
sb=[[] for i in range(n)]
while (i < len) {
for (int j = 0; j < n && i < len; j++)
sb[j].append(c[i++]);
for (int j = n-2; j >= 1 && i < len; j--) //
sb[j].append(c[i++]);
}
How to translate to python? I tried
在 2016年10月14日星期五 UTC-4下午7:35:08,38016...@gmail.com写道:
> nums=['3','30','34','32','9','5']
> I need to sort the list in order to get the largest number string: '953433230'
>
> nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
>
> But how to do this in python 3?
>
> Thank you
!I learn mo
nums=['3','30','34','32','9','5']
I need to sort the list in order to get the largest number string: '953433230'
nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True)
But how to do this in python 3?
Thank you
--
https://mail.python.org/mailman/listinfo/python-list
Google told me Python name is a label attaching to the object.
But in this recursive function,the name 'a' will point to different number
object.
def rec(a):
a+=1
if a<10:
rec(a)
print(a)
rec(0) gives me 101 normally.Why it works? Because of the stack
在 2016年10月2日星期日 UTC-4下午1:05:58,Peter Pearson写道:
> On Sat, 1 Oct 2016 18:12:29 -0700 (PDT), 38016226...@gmail.com wrote:
> > I am trying to print a simple decision tree for my homework.
> > The answer must keep in this format:
> >
> > Top 7,4,0.95
> > career gain = 100
> > 1.Management 2, 3, 0.9
I am trying to print a simple decision tree for my homework.
The answer must keep in this format:
Top 7,4,0.95
career gain = 100
1.Management 2, 3, 0.9709505944546686
2.Service 5, 1, 0.6500224216483541
location gain = 100
1.Oregon 4, 1, 0.7219280948873623
2.Californ
I want to find a python book like C++ primer which provides me details to
understand the language.
--
https://mail.python.org/mailman/listinfo/python-list
A=["1","2","3"]
print(list(map(float,A)).insert(0,1))
I want to insert 1 at the head of the list but this gives me a surprise
--
https://mail.python.org/mailman/listinfo/python-list
在 2016年9月20日星期二 UTC-4下午3:11:27,Terry Reedy写道:
> On 9/20/2016 9:12 AM, Peter Otten wrote:
>
> >> 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道:
> >>> On 20/09/2016 13:12, 38016226...@gmail.com wrote:
> >>> d = {}
> >>> keys = range(256)
> >>> vals = map(chr, keys)
> >>> map(operator.setite
在 2016年9月20日星期二 UTC-4上午9:35:50,Random832写道:
> On Tue, Sep 20, 2016, at 09:19, 38016226...@gmail.com wrote:
> > >>> x = [1, 2, 3]
> > >>> y = [4, 5, 6]
> > >>> zipped = zip(x, y)
> > >>> list(zipped)
> > [(1, 4), (2, 5), (3, 6)]
> > >>> x2, y2 = zip(*zip(x, y))
> > >>> x == list(x2) and y == list(y2
在 2016年9月20日星期二 UTC-4上午9:13:35,Peter Otten写道:
> 38016226...@gmail.com wrote:
>
> > 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道:
> >> On 20/09/2016 13:12, 38016226...@gmail.com wrote:
> >> d = {}
> >> keys = range(256)
> >> vals = map(chr, keys)
> >> map(operator.setitem, [d]*len(key
>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> zipped = zip(x, y)
>>> list(zipped)
[(1, 4), (2, 5), (3, 6)]
>>> x2, y2 = zip(*zip(x, y))
>>> x == list(x2) and y == list(y2)
True
My problem is >>> x2, y2 = zip(*zip(x, y)).
zip return an iterator but x2 and y2 are different?
I really need detail explanatio
在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道:
> On 20/09/2016 13:12, 38016226...@gmail.com wrote:
> d = {}
> keys = range(256)
> vals = map(chr, keys)
> map(operator.setitem, [d]*len(keys), keys, vals)
> >
> > It is from python library. What does [d]*len(keys) mean?
> > d is the name
>>> d = {}
>>> keys = range(256)
>>> vals = map(chr, keys)
>>> map(operator.setitem, [d]*len(keys), keys, vals)
It is from python library. What does [d]*len(keys) mean?
d is the name of dict but put d in [] really confused me.
--
https://mail.python.org/mailman/listinfo/python-list
15 matches
Mail list logo