- """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 10 minutes ago Re: What is in Your Mind? View the latest post Replies 687 Views 274092
- by Eli 1 day ago Iran Launches Retaliatory Attack Against Israel, and Israel Retaliates by Attacking Iranian Isfahan Millitary Base View the latest post Replies 28 Views 884
- by Eli 3 days ago All in One: YouTube, TED, X, Facebook and Instagram Reels, Videos, Images and Text Posts View the latest post Replies 319 Views 8959
- by Eli 5 days ago Python Packages for Scientific Computing View the latest post Replies 8 Views 3001
- by Eli 5 days ago Dunia Yetu: Building Tanzania's Digital Future Together View the latest post Replies 5 Views 1839
- by Eli 1 week ago Russia Invades Ukraine View the latest post Replies 646 Views 210459
- by Eli 1 week ago Programmatically Move Files from One Folder to Another View the latest post Replies 6 Views 1428
- by Eli 2 weeks ago Collection of Greatest Christian Hymns of all Times View the latest post Replies 33 Views 43739
- by Eli 2 weeks ago What is Retrieval-Augmented Generation (RAG)? View the latest post Replies 2 Views 358
- by Eli 2 weeks ago Chat With ChatGPT - An Interactive Conversational AI View the latest post Replies 22 Views 24361
-
Iterating over Python Lists
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5332
- 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