Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a list of tuples:

list_of_tuples = [('4', 35.26), ('1', 48.19), ('5', 90.0), ('3', 90.0)]

tuple[0] is an item_ID

tuple[1] is an angle

I have a list of item_IDs I want to remove/ignore from the list:

ignore_IDs = [5, 3]

I need to find the smallest angle in the list_of_tuples as long as its ID is not in ignore_IDs.

This is used in a function where the angles change and the IDs to ignore change.

Can anyone help me out?

Apologies if explained badly.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
199 views
Welcome To Ask or Share your Answers For Others

1 Answer

Something like this would do, if I didn't misunderstood:

min([t[1] for t in list_of_tuples if int(t[0]) not in ignore_IDs])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...