永发信息网

关于Python的列表添加问题,急!!!!

答案:5  悬赏:80  手机版
解决时间 2021-03-09 18:48
  • 提问者网友:玫瑰园
  • 2021-03-08 20:36
题目:Below your code, create a list calledstudents that contains lloyd, alice, and tyler.
我的代码:students = ["Lloyd", "Alice", "Tyler"]
错误提示:Oops, try again. It looks like Lloyd is not in the students list.
为什么啊!!急!!!
最佳答案
  • 五星知识达人网友:酒者煙囻
  • 2021-03-08 22:07
试一下:
students = [lloyd, alice, tyler]

The names of the three variables that refer to the dictionaries are lloyd,alice, and tyler, and they do not begin with uppercase letters, and should not be enclosed in quotes.
全部回答
  • 1楼网友:上分大魔王
  • 2021-03-09 02:45
input是python3中的数据输入命令; 在python2中,从控制台输入数据是raw_input; 如下所示: python 3.2.3 (default, feb 20 2013, 17:02:41) [gcc 4.7.2] on linux2 type "help", "copyright", "credits" or "license" for more information. >>> a = [] >>> for i in range(3): ... a.append(input("enter: ")) ... enter: 1 2 3 enter: 3 4 5 enter: 5 6 7 >>> a ['1 2 3', '3 4 5', '5 6 7'] >>> python 2.7.3 (default, jan 2 2013, 16:53:07) [gcc 4.7.2] on linux2 type "help", "copyright", "credits" or "license" for more information. >>> a = [] >>> for i in range(3): ... a.append(raw_input("enter: ")) ... enter: 1 2 3 enter: 4 5 6 enter: 7 8 9 >>> >>> a ['1 2 3', '4 5 6', '7 8 9'] >>>
  • 2楼网友:平生事
  • 2021-03-09 01:29
大小写问题吧。
  • 3楼网友:你可爱的野爹
  • 2021-03-09 00:57
student.append('要添加的名称')#默认添加到最后一个
  • 4楼网友:动情书生
  • 2021-03-08 23:38
>>> students = ["Lloyd", "Alice", "Tyler"] >>> students ['Lloyd', 'Alice', 'Tyler'] >>> 没错啊.
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯