Apr-13-2017, 04:28 PM
Hello dear readers,
I'm very new to Python, I started reading and following some tutorials on Python 2 days ago. A long long time ago, like 10years ago, I used to code PHP and make websites with html, js, php, mySQL and css just came up. I didn't follow thrue with coding or programming ever since.
Now I recently changed job and have some spare time I decided to pick up coding/programming again and found myself pretty interested in Python, due to the great accescibility and maybe potential job possibilities in the future.
I've been trying out some code and it's in a very early stage, it works but just since I'm really not familiar with Python functionality or possibilities I was just wondering if there's a way to optimise my code. In a later stage I'm going to implement some way to load the lists of names in the Variables "RuilenVanaf" & "RuilenNaar" but since I'm just learning I dont feel the need to do this right away, I just try to implement what I've learned from tutorials into code.
What the code should do: Compare what coworkers are in the list "RuilenVanaf" and what coworkers are in the list "RuilenNaar", if the match they should be stored in "Ruilen", pretty straight forward. Any way of optimising this code? Or any tips at al?
[Ashamed] I can't find an edit button, fyi the outcome of this code is:
['vivian', 'dalton', 'pim', 'Roy', 'Beckey']
I'm very new to Python, I started reading and following some tutorials on Python 2 days ago. A long long time ago, like 10years ago, I used to code PHP and make websites with html, js, php, mySQL and css just came up. I didn't follow thrue with coding or programming ever since.
Now I recently changed job and have some spare time I decided to pick up coding/programming again and found myself pretty interested in Python, due to the great accescibility and maybe potential job possibilities in the future.
I've been trying out some code and it's in a very early stage, it works but just since I'm really not familiar with Python functionality or possibilities I was just wondering if there's a way to optimise my code. In a later stage I'm going to implement some way to load the lists of names in the Variables "RuilenVanaf" & "RuilenNaar" but since I'm just learning I dont feel the need to do this right away, I just try to implement what I've learned from tutorials into code.
What the code should do: Compare what coworkers are in the list "RuilenVanaf" and what coworkers are in the list "RuilenNaar", if the match they should be stored in "Ruilen", pretty straight forward. Any way of optimising this code? Or any tips at al?
RuilenVanaf = ["vivian", "dalton", "pim", "Tom", "Raymond", "Roy", "Leon", "Beckey", "Ridha", "Kevin", "Sjaak"] RuilenNaar = ["vivian", "eyewumi", "dalton", "pim", "floor", "Roy", "Beckey"] iAantalNaar = len(RuilenNaar) iAantalVanaf = len(RuilenVanaf) Ruilen = [] if iAantalNaar > iAantalVanaf: n = iAantalNaar s = iAantalVanaf for n in range(n): # print(n) if RuilenNaar[n] in RuilenVanaf: # print(RuilenNaar[n], "match") Ruilen.append(RuilenNaar[n]) continue # else: # print(RuilenNaar[n], " geen match") else: n = iAantalVanaf s = iAantalNaar for n in range(n): # print(n) if RuilenVanaf[n] in RuilenNaar: # print(RuilenVanaf[n], "match") Ruilen.append(RuilenVanaf[n]) continue # else: # print(RuilenVanaf[n], " geen match") print(Ruilen)
[Ashamed] I can't find an edit button, fyi the outcome of this code is:
['vivian', 'dalton', 'pim', 'Roy', 'Beckey']