python - 如何在不使用内置函数的情况下从python中的数组中删除元素
问题描述
如何在不使用python内置函数的情况下删除数组中的元素
我已经用内置函数尝试过这个程序,但没有它们我不知道怎么做
c = [6,7,8,9]
c.remove(c[0])
print(c)
我得到了预期的结果,但我想要它而不使用 python 中的内置函数。
解决方案
这应该可以,但是此方法会创建一个新数组
c=[6,7,8,9]
d=[]
a=0
for x in c:
if x!=c[a]: #or you write c[0] and remove the a=0
d.append(x)
print(d)
推荐阅读
- node.js - Jenkins(声明性管道)阶段挂起硒测试
- r - 在easyABC R包中设置一个长的汇总统计向量
- r - 合并具有匹配和不同列的多个数据框并放置 NA
- c# - IdentityServer4 Session Cookie Management(如何正确操作?)
- c# - System.Net.Http.HttpRequestException:将内容复制到流时出错。System.IO.IOException:响应提前结束
- reactjs - 使用 react-testing-library 时使用 mocha 和 chai 进行断言?
- javascript - 为什么同一个对象的属性在两个不同的console.log中是不同的?
- php - PHP中的中国等效时区是什么?
- python - 如何在 dict 值中进行数学运算是 python 中的列表?
- docker - android 模拟器没有出现在 noVNC 上(在 docker 容器中)