selfteaching / selfteaching/selfteaching-python-camp

Day05 用for循环加判断条件找出含有ea单词时怎么删除?

Open
#321 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description


如图我的代码。

list = text.split( )#将text的字符串以空格为分割符分割成字符串并赋值给变量list
str1 = "ea"
str2=[]
for i in list:
    if i.find(str1) > -1:
       str2.append(i)
print(list)

我想把找出来的单词塞进一个新的数组,然后把数组全部删掉,怎么删?

还有一个方法是找出来含有ea单词时用remove删除,但是这样会有删除遗漏的问题,如何解决删除不完全的问题?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the Python example in the issue body and review how the list is split, searched, and modified during iteration. Check a filtering or deletion approach that avoids skipped matches; done means every word containing “ea” is removed without omissions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.