Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Dictionary from a list failed, help needed
Post: RE: Dictionary from a list failed, help needed

Thank you all for the wonderful solutions!
leoahum General Coding Help 7 1,958 Apr-27-2022, 02:19 PM
    Thread: Dictionary from a list failed, help needed
Post: RE: Dictionary from a list failed, help needed

Thanks a lot. It is super helpful! FYI, I'm using Ironpython 2.7 that embeded in some other software. (Apr-26-2022, 08:58 PM)bowlofred Wrote: Line4 is a problem. It assumes there is a single defa...
leoahum General Coding Help 7 1,958 Apr-26-2022, 09:11 PM
    Thread: Dictionary from a list failed, help needed
Post: Dictionary from a list failed, help needed

Hi, I am trying to get a dictionary from a list like ["a", "b", "c", "a", "c"]. The out come is expected to be {"a": [0, 3], "b": [1], "c": [2, 4]}. The element of the list is the key and index of th...
leoahum General Coding Help 7 1,958 Apr-26-2022, 08:39 PM
    Thread: How to make this piece concise
Post: How to make this piece concise

I am setting up a script in a 3D modeling program called Rhino(Use ironPython) and its Visual Scripting Tool (Grasshopper). "Active" is an input boolean value. "a" is to output the result. Before the...
leoahum General Coding Help 0 1,329 Sep-23-2021, 09:23 PM
    Thread: Multi-pop using different loops
Post: RE: Multi-pop using different loops

This is a perfect answer to my question. Thanks a lot! (Jan-12-2021, 05:27 PM)bowlofred Wrote: In your first one you are doing the pops in a loop, but you are also making a recursive call to the Mu...
leoahum General Coding Help 6 3,016 Jan-13-2021, 04:59 AM
    Thread: Multi-pop using different loops
Post: RE: Multi-pop using different loops

Thank you for the naming advises. They are helpful. Unfortunately, using slice will not work in my case. The "count" parameter needs to be the quantity of elements pulling out from the rest of the li...
leoahum General Coding Help 6 3,016 Jan-13-2021, 04:58 AM
    Thread: Multi-pop using different loops
Post: RE: Multi-pop using different loops

Thanks Larz60+. I know slice, but my case needs me to get rid of few elements in a certain sequence. (Jan-12-2021, 03:48 PM)Larz60+ Wrote: This is already built into python, called a slice: >&g...
leoahum General Coding Help 6 3,016 Jan-13-2021, 04:41 AM
    Thread: Multi-pop using different loops
Post: Multi-pop using different loops

I'm doing a multi-pop function as following. The goal is to remove the first few elements in a list. For instance, if I have [1,2,3,4,5,6,7,8,9] and set the iter as 3. A list as [4,5,6,7,8,9] are expe...
leoahum General Coding Help 6 3,016 Jan-12-2021, 08:28 AM
    Thread: How do I understand "and" in a loop
Post: RE: How do I understand "and" in a loop

Thanks a lot!
leoahum General Coding Help 2 1,671 Apr-24-2020, 05:57 AM
    Thread: How do I understand "and" in a loop
Post: How do I understand "and" in a loop

Hi, I'm trying to get a better understanding for "and" in a loop. For the script below, I'm trying to get index 1, but it returns index 1 and 2. b = ["abc", "bcd","cde"] for i in range(len(b)): ...
leoahum General Coding Help 2 1,671 Apr-24-2020, 04:53 AM
    Thread: Copy List Structure
Post: RE: Copy List Structure

(Mar-20-2019, 04:09 PM)ichabod801 Wrote: Instead of taking the items off individually, you could take them off in slices: L1 = [[1,2,3],[4,2],[6,8,1],[4,3]] L2 = [1,2,3,4,5,6,7,8,9,10] L3 =[] star...
leoahum General Coding Help 2 2,890 Mar-22-2019, 05:40 PM
    Thread: Copy List Structure
Post: Copy List Structure

L1 = [[1,2,3],[4,2],[6,8,1],[4,3]] L2 = [1,2,3,4,5,6,7,8,9,10] L3 =[] def ListStrcCopy(L1,L2): L = [] for i in L1: L.append (L2.pop(0)) return L for i in L1: L3.append(List...
leoahum General Coding Help 2 2,890 Mar-20-2019, 04:00 PM
    Thread: RecursionError: maximum recursion depth exceeded in comparison ?
Post: RE: RecursionError: maximum recursion depth exceed...

(Mar-15-2019, 08:39 PM)ichabod801 Wrote: Again, you are not being clear. We need the full text of the error you are getting. Here is the full error text message. Traceback (most recent call last): ...
leoahum General Coding Help 11 13,020 Mar-18-2019, 01:53 PM
    Thread: RecursionError: maximum recursion depth exceeded in comparison ?
Post: RE: RecursionError: maximum recursion depth exceed...

(Mar-15-2019, 01:22 PM)ichabod801 Wrote: You put your parameters in the wrong order on line 5. Thanks! But in the scripts below. I meet a similar problem. The function works fine by its own, but wil...
leoahum General Coding Help 11 13,020 Mar-15-2019, 07:35 PM
    Thread: RecursionError: maximum recursion depth exceeded in comparison ?
Post: RE: RecursionError: maximum recursion depth exceed...

(Mar-15-2019, 04:05 AM)ichabod801 Wrote: (Mar-15-2019, 03:03 AM)leoahum Wrote: I was trying to using recursion in a for loop, but it did work as I expected. Could you please show me the right way ...
leoahum General Coding Help 11 13,020 Mar-15-2019, 01:09 PM
    Thread: RecursionError: maximum recursion depth exceeded in comparison ?
Post: RE: RecursionError: maximum recursion depth exceed...

(Mar-15-2019, 12:11 AM)micseydel Wrote: You're using recursion. When you have recursion, you have two situations: a "base case" (where you don't recurse) and a recursive case. The error you're encou...
leoahum General Coding Help 11 13,020 Mar-15-2019, 03:03 AM
    Thread: RecursionError: maximum recursion depth exceeded in comparison ?
Post: RecursionError: maximum recursion depth exceeded i...

def ChangeList (K = [0], itr = 0): if itr < 10: K.append(1) itr += 1 ChangeList() else: return K L = ChangeList() print (L)I'm trying to get a list from ...
leoahum General Coding Help 11 13,020 Mar-14-2019, 10:16 PM
    Thread: Redundant Iterations
Post: RE: Redundant Iterations

(Mar-13-2019, 07:11 PM)ichabod801 Wrote: It's not clear, because you haven't shown us how you call Optm in the first place. But if you only want the else clause to execute if none of the if clauses ...
leoahum General Coding Help 3 2,076 Mar-13-2019, 07:15 PM
    Thread: Redundant Iterations
Post: Redundant Iterations

OrgH = [73.35,111.37,92.70,70.73,67.71,77.84] BtmGap = 32 MinRH = 12 Div = 7 tH = 400 sH = sum(OrgH) q = Div - len(OrgH) def Optm(S, H, GH, q): s = H + GH L = [S,GH] if S >= s: ...
leoahum General Coding Help 3 2,076 Mar-13-2019, 06:29 PM
    Thread: Replace with Maximum Value
Post: RE: Replace with Maximum Value

(Mar-11-2019, 09:12 PM)Yoriz Wrote: Another my_list = [[0,1,2],[4,5,6,7],[7,8,9,10]] new_list = [[max(each)]*len(each) for each in my_list] print(new_list)Output:[[2, 2, 2], [7, 7, 7, 7], [10, 10, 1...
leoahum General Coding Help 4 2,507 Mar-13-2019, 06:24 PM

User Panel Messages

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