Sometimes, I have to use while statement too. But any time, I think 
write right code, write clean code,  It's a basic rule for our develope work.




moqianc...@gmail.com

From: hito koto
Date: 2014-06-11 21:05
To: django-users
Subject: Re: Django Python roop

Hi, qiancong:
Thank you,
Do you not use the while statement to Django?


2014年6月11日水曜日 21時52分54秒 UTC+9 Qiancong:
 
Hi, hito koto:
I think  the problems you asked should be post in python-lang mail-list. 
For python program,  I prefer "for", not "while";  It's more simpler.
But  if you like while, I think the following code maybe helpful:

def fff(x):
y = []
i = 0
xlen = len(x)
while i< xlen:
y.append(x[i])
i += 1
return y

but I more like the follow writing:
def fff(x):
return x[:]

or you just do as following:
y  = x[:]

python is a power & beautiful language,   
please read the  https://docs.python.org/2/tutorial/ at first like  François 
said.

With Regards.




moqia...@gmail.com

From: hito koto
Date: 2014-06-11 19:21
To: django-users
Subject: Django Python roop
Hello, all

I want to change to while statement from for statement, so how can i do to?

this is my correct for statement codes:

def fff(x):
    y = []
    for i in range(len(x)):
        y.append(x[i])
    return y

and i want change to while statement 

So, this code have erroes:
TypeError: list indices must be integers, not list
def fff(x):
    y = []
    while x !=[]:
       for i in x:
           y.append(x[i])
    return y

-- 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8afde78f-9910-4d26-b1e6-e5f1eaaca63b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2014061121121170324647%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to