- """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 Eli 31 minutes ago All in One: YouTube, TED, X, Facebook and Instagram Reels, Videos, Images and Text Posts View the latest post Replies 283 Views 6571
- by Eli 2 hours ago CAF Champions League Quarter Finals: Simba vs Al Ahyl View the latest post Replies 1 Views 27
- by Eli 20 hours ago Russia Invades Ukraine View the latest post Replies 643 Views 209069
- by Eli 20 hours ago Collection of Greatest Christian Hymns of all Times View the latest post Replies 30 Views 42704
- by Eli 1 day ago Chat With ChatGPT - An Interactive Conversational AI View the latest post Replies 21 Views 22729
- by Eli 6 days ago Re: What is in Your Mind? View the latest post Replies 658 Views 271408
- by Eli 6 days ago Mission Control Live: NASA InSight Mars Landing Live Coverage View the latest post Replies 32 Views 12967
- by Eli 6 days ago Christian Podcasts View the latest post Replies 4 Views 28285
- by Eli 1 week ago Python Packages for Scientific Computing View the latest post Replies 7 Views 2715
- by Eli 1 week ago Pondering Big Cosmology Questions Through Lectures and Dialogues View the latest post Replies 32 Views 44755
-
Iterating over Python Lists
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5224
- 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