- """Remove al 2's from the list"""
- x = [2,2,2,2,2,5,6,7,8,9,2,2,2]
- def Remove_2():
- for number in x:
- if number==2:
- x.remove(number)
- return x
- print ("The list without 2's:", Remove_2())
-
- Active Topics
-
-
- by RealityKing 2 hours ago All in One: YouTube, TED, X, Facebook and Instagram Reels, Videos, Images and Text Posts View the latest post Replies 274 Views 6525
- by Eli 11 hours ago Russia Invades Ukraine View the latest post Replies 643 Views 209057
- by Eli 12 hours ago Collection of Greatest Christian Hymns of all Times View the latest post Replies 30 Views 42694
- by Eli 1 day ago Chat With ChatGPT - An Interactive Conversational AI View the latest post Replies 21 Views 22690
- by Eli 5 days ago Re: What is in Your Mind? View the latest post Replies 658 Views 271378
- by Eli 6 days ago Mission Control Live: NASA InSight Mars Landing Live Coverage View the latest post Replies 32 Views 12962
- by Eli 6 days ago Christian Podcasts View the latest post Replies 4 Views 28282
- by Eli 1 week ago Python Packages for Scientific Computing View the latest post Replies 7 Views 2713
- by Eli 1 week ago Pondering Big Cosmology Questions Through Lectures and Dialogues View the latest post Replies 32 Views 44705
- by Eli 2 weeks ago C++ PROGRAMMING CRASH COURSE View the latest post Replies 4 Views 1292
-
Iterating over Python Lists
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5214
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
What will the following Python program do?
My intention is that the code will delete all 2's from the list x and return a new list without 2's, why the program will not work the way I think?
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
-
- Similar Topics
- Replies
- Views
- Last post
-
- Information
-
Who is online
Users browsing this forum: No registered users and 0 guests