Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Python
list1 = [5, 20, 15, 20, 25, 50, 20]


as you can see the list has been declared, now what I've must do is
1. remove all the elements valued at 20 and save them in the variable list2. After that print the variable list2.
2. from variable list 2. if has been found element valued at 15, changed to 10 and saved in the variable list3. also, print the list3
Sincerely, thanks before guys

What I have tried:

I have tried using function pops but it seems I just lost
Posted
Updated 11-Apr-22 17:00pm
v4
Comments
Maciej Los 11-Apr-22 15:25pm    
Sounds like homework.
What code have you tried to use?

from https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range check out the index() operation
 
Share this answer
 
Check the nice article on list operation in Python. Try yourself to learn more:
https://www.guru99.com/python-list-remove-clear-pop-del.html[^]
How to Remove Duplicates from a List in Python | Career Karma[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900