Codecademy上python的一道问题卡住了
伊谢尔伦
伊谢尔伦 2017-04-17 14:36:30
[Python讨论组]

Instructions
01.Define a function called print_list that has one argument called x.
02.Inside that function, print out each element one by one. Use the existing code as a scaffold.
03.Then call your function with the argument n.

原来的代码是:

n = [3, 5, 7]

for i in range(0, len(n)):
    print n[i]

根据题目要求写的代码:

n = [3, 5, 7]

for i in range(0, len(n)):
    print n[i]

def print_list(x):
    for i in range(0,len(x)):
        print x[i]

print_list(n)

不知哪里出错了,显示:The body of your function should not contain any references to 'n'

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(2)
PHP中文网

好吧 - -!我总算看懂了,要把
for i in range(0, len(n)): print n[i]
删掉。是我太......

高洛峰

我也刚好练习到这里,遇到跟你一样的问题。
删掉你说的那段就好了。为什么要删掉啊

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号