鱼C论坛

 找回密码
 立即注册
查看: 1850|回复: 2

[已解决]列表习题

[复制链接]
发表于 2021-10-11 15:06:01 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
欲将4个字的桥名找出来,组成一个新的列表。
bridge=list(["海津大桥","广场桥","解放桥","大沽桥","赤峰桥","保定桥","直沽桥","富民桥","金刚桥","金汤桥","北安桥","狮子林桥","永乐桥","大光明侨","刘庄浮桥","国泰桥"])
bridge_4=0
for i in range (len(bridge)) :
    if bridge[i] % 4 ==0 :
        bridge_4[i].append(bridge[i])
print(bridge_4)

运行程序后,报错呀 ?
最佳答案
2021-10-11 15:14:30
bridge=list(["海津大桥","广场桥","解放桥","大沽桥","赤峰桥","保定桥","直沽桥","富民桥","金刚桥","金汤桥","北安桥","狮子林桥","永乐桥","大光明侨","刘庄浮桥","国泰桥"])
bridge_4=[]
for i in range (len(bridge)) :
    if len(bridge[i]) % 4 ==0 :
        bridge_4.append(bridge[i])
print(bridge_4)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-11 15:14:30 | 显示全部楼层    本楼为最佳答案   
bridge=list(["海津大桥","广场桥","解放桥","大沽桥","赤峰桥","保定桥","直沽桥","富民桥","金刚桥","金汤桥","北安桥","狮子林桥","永乐桥","大光明侨","刘庄浮桥","国泰桥"])
bridge_4=[]
for i in range (len(bridge)) :
    if len(bridge[i]) % 4 ==0 :
        bridge_4.append(bridge[i])
print(bridge_4)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-11 15:15:28 | 显示全部楼层
bridge=list(["海津大桥","广场桥","解放桥","大沽桥","赤峰桥","保定桥","直沽桥","富民桥","金刚桥","金汤桥","北安桥","狮子林桥","永乐桥","大光明侨","刘庄浮桥","国泰桥"])
bridge_4=[]
for i in bridge :
    if len(i) % 4 ==0 :
        bridge_4.append(i)
print(bridge_4)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-1-13 06:27

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表