python的可选参数问题,零基础,处于自学状态,真的好困惑啊大神们
ringa_lee
ringa_lee 2017-04-18 10:28:16
0
3
623
movies=["A","B",["C",["D"]]]

print_lol(movies,0)

def print_lol(the_list,level):
    for each_item in the_list:
        if isinstance(each_item,list):
           print_lol(each_item,level+1)
        else:
           for tab_stop in rang(level):
               print("\t",end='')
           print(each_item)

我想知道这个哪出错了,是这样的,这个问题的前面一点讲的是python语言的发布问题嘛,然后我看得一愣一愣的,看不懂,又叫我建文件夹有什么的,我真的不懂啊,然后往后看,讲的就是level这个参数,然后又讲了可选参数,它没有给出完整的代码出来,以上这个是我自己摸索得出的,就是不知道对不对,然后系统显示错误,可是我看不懂哇,然后想请大神赐教,我不知道和前面那个发布问题有没关系,

NameError                         Traceback (most recent call last)
NameError: name 'rang' is not defined

这个是错误提示

ringa_lee
ringa_lee

ringa_lee

reply all(3)
ringa_lee

It’s been one year, time flies by, thank you php Chinese website! I learned a lot!!! Optional parameters of python

巴扎黑

should be range 而不是 rang

Also, when asking questions about python, be sure to indicate Python2 还是 Python3

Ty80

Be familiar with the language’s error prompts and common error types.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!