Python deepcopy to while statement

hito koto hitokoto2014 at gmail.com
Fri Jun 13 01:40:09 EDT 2014


2014年6月13日金曜日 12時47分19秒 UTC+9 hito koto:
> Hi, all
> 
> 
> 
> I want to make the function use while statement,and  without a deepcopy functions.
> 
> 
> 
> this is my use deepcopy  function correct codes, So, how can i to do a different way  and use while statement:
> 
> 
> 
> def foo(x):
> 
>     if not isinstance(x, list):
> 
>         return x
> 
>     return [foo(y) for y in x]


I write this code but this is not copy:
maybe noe more write while statements: but i can't.

def foo(x):
    y = []
    i = len(x)-1
    while i >= 0:
        y.append(x[i])
        i -= 1
    return y



More information about the Python-list mailing list