Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: How do I make zip() append a value to a key?
Post: How do I make zip() append a value to a key?

I have these two arrays: arr1 = ['sub1', 'sub1', 'sub2', 'sub1', 'sub1', 'sub2']arr2 = [1.9 , 2.2 , 9.1 , 7.3 , 4.0 , 5.1 ]When I do dict(zip(arr1, arr2,)) I get sub1 : 4, sub2 : 5.1 where...
rm197 General Coding Help 1 1,311 Oct-01-2019, 06:18 PM
    Thread: Creating a list from a comprehension using a list
Post: RE: Creating a list from a comprehension using a l...

(Sep-30-2019, 06:54 PM)stullis Wrote: Okay, now I'm tracking. To do that, we need to move jsonData into the comprehension. keyIDs = list(jsonData.keys()) #list of IDs listOfValsFromKeys = [jsonDa...
rm197 General Coding Help 6 2,668 Sep-30-2019, 07:02 PM
    Thread: Creating a list from a comprehension using a list
Post: RE: Creating a list from a comprehension using a l...

(Sep-30-2019, 06:46 PM)stullis Wrote: Trying to do what with comprehensions instead of loops. Replacing "students" with "jsonData" will still have the same error. What is the end goal? keyIDs = list...
rm197 General Coding Help 6 2,668 Sep-30-2019, 06:52 PM
    Thread: Creating a list from a comprehension using a list
Post: RE: Creating a list from a comprehension using a l...

(Sep-30-2019, 06:41 PM)stullis Wrote: It isn't clear what you're trying to accomplish. students[...] suggests slicing a sequence named "students", but you can't use a list comprehension for that. Pl...
rm197 General Coding Help 6 2,668 Sep-30-2019, 06:43 PM
    Thread: Creating a list from a comprehension using a list
Post: Creating a list from a comprehension using a list

keyIDs = list(jsonData.keys()) #list of IDs listOfValsFromKeys = students[keyIDs[i] for i in range(len(keyIDs))] #list of namesWhen I run the lines above, I get a syntax error in between the 'for...
rm197 General Coding Help 6 2,668 Sep-30-2019, 06:23 PM

User Panel Messages

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