python入门写了一条错误语句…………求指出错误的地方……
movies=["a","b","c",["iq","eq"]foreach_iteminmovies:ifisinstance(each_item,list):prin...
movies=["a","b","c",["iq","eq"]
for each_item in movies:
if isinstance(each_item,list):
print(each_item)
else:
这里按下确定键就出现语法错误了……………… 展开
for each_item in movies:
if isinstance(each_item,list):
print(each_item)
else:
这里按下确定键就出现语法错误了……………… 展开
展开全部
你这里的问题出现在movies的赋值里面,你后面少打一个方略括号,另外还要注意缩进问题,应该是这样:
movies = ["a","b","c",["iq","eq"]]
for each_item in movies:
if isinstance(each_item,list):
print(each_item)
else: +你后面的语句
这样如果忽略else后面的语句,输出的就如下:
>>> ['iq', 'eq']
若不懂,请追问,望采纳!
movies = ["a","b","c",["iq","eq"]]
for each_item in movies:
if isinstance(each_item,list):
print(each_item)
else: +你后面的语句
这样如果忽略else后面的语句,输出的就如下:
>>> ['iq', 'eq']
若不懂,请追问,望采纳!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询