题解 | #格式化清单#--循环语句执行前后
格式化清单
https://www.nowcoder.com/practice/91041d28883847d2af52e98e3df14b53
eat_list = ["apple","ice cream","watermelon","chips","hotdogs","hotpot"]
while len(eat_list) != 0:
#while eat_list != []:
eat_list.pop()
print(eat_list)
循环语句:
有循环语句时要注意判断条件和循环内部操作的对应,确定执行到哪一步
list的空值判断:
√:可以用空列表,可以用长度;
×:python中没有null,有none,但是判断一个列表是否为空时,不能使用None。原因是None在Python中是一个特殊的常量,表示“无值”或“空值”,而不是一个列表。


智元机器人成长空间 206人发布