开发者

How to pass value for python for loop?

In C/C++:

for(int i=0;i<=5;i++)

In Python:

for i in range(0,5)

Question is:

s=[1,2,3,4,1]

for i in s:
    for j in s:

Here i wanna make second for loop j=1 (j value should be start with 1 like this s[1]=2).How do 开发者_Python百科i pass that value.


You should ask this on stackoverflow, but the answer is (if I got you right):

for i in s:
   for j in s[1:]:

Read this chapter about lists in python, this will help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜