Write a function called NumDistinctDict that takes a single parameter alist that determines the number of distinct values in alist. For example, the list [1,2,4,2,7] contains 3 unique values (namely 1,2,4 and 7).
kenmeck03
0
Newbie Poster
Recommended Answers
Jump to PostThis sounds suspiciously like homework, so I'll just give you a hint.
someList.index(item) returns the index of the item if it's in some list. Otherwise, it'll throw ValueError.
Example:
listA = [1,2,3,5] try: listA.index(4) print "Four is in the list." except ValueError: print "Four isn't …
All 4 Replies
Mathhax0r
2
Junior Poster in Training
woooee
814
Nearly a Posting Maven
masterofpuppets
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.