Number removing trick using Python

Well, there are thousands of tricks which can be performed using python. So, here I’m bringing one more python trick for you’ll.
Okay, but the condition is that you don’t have to use your terminal for answering this question, yes, because it’s an easy one. So you just don’t need a terminal at all.
This is simple trick in python related to “greater than” or “less than” which we all studied in junior classes and we’ll did it correctly.
So, its time to remember those days and try to find out the correct answer of the python program.

Here is the code :

some_list = [1, 2, 3, 4, 5, 6]

for item in some_list:

    if item < 4:

        some_list.remove(item)

print some_list

Problem looks easy ? Okay, try figuring out the answer without using a python interpretor.

Advertisements

One thought on “Number removing trick using Python

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s