Python Forum
count unique values of a list with a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
count unique values of a list with a list
#1
so I'm fiddling with lists ... (and yup, new in python)

mylist = ["a", "b", "c"]
where "a,b,c" are lists with some values too ... like
"a" > {"longname", "1234"}
"b" > {"longname", "1223434"}
"c" > {"longnaaame", "12314444223234"}
keyword = "name"


I want my primary list to be checked with unique values on the nested list values.
So in this example the result would be '2' since 'name' occurs in 'a' and in 'b'.

Afterwards I could use len to check.

I'm thinking
ulist = []
for l in mylist:
> for nl in l
>> if keyword in nl:
>>> ulist.append(l)
Makes sense? I hope so. This the way to do so?

(later on I want to check if there is 'one' item in the list ... if so ... do something ... else ... etc.)
Reply


Messages In This Thread
count unique values of a list with a list - by 3Pinter - Jul-05-2018, 09:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Assigning cycle values in a list nmancini 3 937 Sep-16-2024, 09:35 PM
Last Post: deanhystad
  remove duplicates from dicts with list values wardancer84 27 5,524 May-27-2024, 04:54 PM
Last Post: wardancer84
  Strange behavior list of list mmhmjanssen 3 1,565 May-09-2024, 11:32 AM
Last Post: mmhmjanssen
  Get an average of the unique values of a column with group by condition and assign it klllmmm 0 1,907 Feb-17-2024, 05:53 PM
Last Post: klllmmm
  Copying the order of another list with identical values gohanhango 7 2,510 Nov-29-2023, 09:17 PM
Last Post: Pedroski55
  Sample random, unique string pairs from a list without repetitions walterwhite 1 1,808 Nov-19-2023, 10:07 PM
Last Post: deanhystad
  Search Excel File with a list of values huzzug 4 2,744 Nov-03-2023, 05:35 PM
Last Post: huzzug
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 2,566 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  Function to count words in a list up to and including Sam Oldman45 15 10,337 Sep-08-2023, 01:10 PM
Last Post: Pedroski55
  Comparing List values to get indexes Edward_ 7 3,260 Jun-09-2023, 04:57 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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