- """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 1 hour ago Russia Invades Ukraine View the latest post Replies 658 Views 225836
- by Eli 2 hours ago Re: What is in Your Mind? View the latest post Replies 698 Views 290178
- by Eli 1 day ago President Museveni's Speech During International Development Association (IDA) Summit View the latest post Replies 1 Views 55
- by Eli 1 day ago From Simple Linear Regression Analysis to Covariance & Correlation to Independent Determinant, and R-Squared View the latest post Replies 11 Views 24357
- by Eli 1 day ago All in One: YouTube, TED, X, Facebook and Instagram Reels, Videos, Images and Text Posts View the latest post Replies 323 Views 24931
- by Eli 4 days ago Collection of Greatest Christian Hymns of all Times View the latest post Replies 34 Views 58743
- by Eli 4 days ago Pondering Big Cosmology Questions Through Lectures and Dialogues View the latest post Replies 34 Views 57628
- by Eli 6 days ago Programmatically Manipulate Files: Renaming, Reading, Writing, Deleting, and Moving Files Between Folders View the latest post Replies 7 Views 7758
- by Eli 1 week ago Iran Launches Retaliatory Attack Against Israel, and Israel Retaliates by Attacking Iranian Isfahan Millitary Base View the latest post Replies 28 Views 7362
- by Eli 2 weeks ago Python Packages for Scientific Computing View the latest post Replies 8 Views 13919
-
Iterating over Python Lists
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5368
- 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 2 guests