Python Forum
List of far points of two list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List of far points of two list
#1

I'm trying to create a program that for two list xs and ys, return a list zs with only the element of ys that their distance of any element of xs be at least d.
def distance(a,b):
    y=sqrt((a.real-b.real)**2+(a.imag-b.imag)**2)
    return y


    

def dist(xs,ys,d):
    zs=[]
    for i in range(0,len(xs)-1):
        for k in range(0,len(ys)-1):
            if distancia(xs[i],ys[k])<=d:
                zs=zs 
                break
            else:
                zs=zs+[ys[i]]
    return zs
But it's wrong, and I don't know how to fixed it. Could you help me please?.

Thank you.
Reply


Messages In This Thread
List of far points of two list - by antoniomancera - Nov-15-2017, 04:21 PM
RE: List of far points of two list - by sparkz_alot - Nov-16-2017, 12:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to reverse a list and store in another list in python SuperNinja3I3 6 4,572 Aug-14-2022, 06:36 PM
Last Post: DeaD_EyE
Question Python - List - Int List sophi 8 5,690 Apr-21-2022, 07:55 PM
Last Post: sophi
  Check if a list exists in given list of lists Daniel94 2 2,900 Apr-07-2020, 04:54 PM
Last Post: deanhystad
  list of strings to list of float undoredo 3 4,092 Feb-19-2020, 08:51 AM
Last Post: undoredo
  arrays sum list unsupported operand type(s) for +=: 'int' and 'list' DariusCG 7 5,957 Oct-20-2019, 06:24 PM
Last Post: Larz60+
  have homework to add a list to a list using append. celtickodiak 2 2,663 Oct-11-2019, 12:35 PM
Last Post: ibreeden
  Search character from 2d list to 2d list AHK2019 3 3,371 Sep-25-2019, 08:14 PM
Last Post: ichabod801
  I donr know how to search from 2d list to 2d list AHK2019 1 2,391 Sep-25-2019, 01:59 AM
Last Post: ichabod801
  sort a list alphabeticaly without changing the original list Holmen 5 5,460 Jan-27-2019, 01:49 PM
Last Post: Holmen
  making a dictionary from a list, one key with multiple values in a list within a list rhai 4 4,599 Oct-24-2018, 06:40 PM
Last Post: LeSchakal

Forum Jump:

User Panel Messages

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