Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python code snippet
#4
That will behave *almost* the same unless you're modifying M somewhere. Otherwise, you're just replacing x >= 10 with x >= M[i], which will always be M[0] or M[1]. You still have a huge potential for an index error.

If
[L[i] for i in range(2) if x >= M[i] and x < M[i+1]]
creates an empty list, then there won't be an item to index at [0].

What are you trying to accomplish?
Reply


Messages In This Thread
python code snippet - by chinna - Mar-13-2019, 04:40 PM
RE: python code snippet - by Shay - Mar-13-2019, 05:11 PM
RE: python code snippet - by chinna - Mar-13-2019, 05:58 PM
RE: python code snippet - by Shay - Mar-13-2019, 07:46 PM
RE: python code snippet - by chinna - Mar-15-2019, 06:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in output of a snippet code akbarza 2 417 Feb-28-2024, 07:15 PM
Last Post: deanhystad
  [Solved] Trying to rerun a snippet of code paracel 3 1,179 Jul-17-2022, 01:49 PM
Last Post: paracel
  Can someone explain this small snippet of code like I am a 5 year old? PythonNPC 3 1,278 Apr-08-2022, 05:54 PM
Last Post: deanhystad
  English interpretation of the following file handing snippet mortch 5 3,214 May-30-2019, 08:10 AM
Last Post: mortch
  Unable to read csv file inside full code snippet, at the same time its working seprat sreeraj 2 3,042 Jan-28-2018, 07:25 PM
Last Post: sreeraj

Forum Jump:

User Panel Messages

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