Python Forum
.remove() method in for-loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.remove() method in for-loop
#6
Yes, but set will change the order and remove duplicates. That may be desired behavior. And you didn't test filter. If you add

def time_5(lst):
    sw = filter(lambda item: item != 'bo', lst)
Then the short list times are:

Output:
time_1 --> 9.78 time_2 --> 4.95 time_3 --> 6.95 time_4 --> 7.73 time_5 --> 3.40
And the long list times are:

Output:
time_1 --> 4.09 time_2 --> 0.18 time_3 --> 0.07 time_4 --> 7.32 time_5 --> 0.03
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
.remove() method in for-loop - by nzcan - Oct-08-2018, 07:39 PM
RE: .remove() method in for-loop - by ichabod801 - Oct-08-2018, 08:25 PM
RE: .remove() method in for-loop - by TimeMen - Oct-08-2018, 08:30 PM
RE: .remove() method in for-loop - by ichabod801 - Oct-08-2018, 08:34 PM
RE: .remove() method in for-loop - by snippsat - Oct-08-2018, 10:23 PM
RE: .remove() method in for-loop - by ichabod801 - Oct-09-2018, 01:04 AM
RE: .remove() method in for-loop - by snippsat - Oct-09-2018, 02:07 PM
RE: .remove() method in for-loop - by gruntfutuk - Oct-13-2018, 07:05 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020