So I wrote a python that will find what the pin the users inputs, everything works fine except one thing, and that's that the script won't exist once the pin is found. Is there a why I can kill all of the other threads once I found the pin?
#!/usr/bin/env python
#
#
#
from threading import Thread
from random import randint
from time import sleep
from sys import exit
from os import system
system('clear');sleep(0.7)
Pin = int(raw_input('Enter a pin: '))
def Up():
global Pin
for pin in xrange(1111,10000):
system('clear')
print pin
if pin == Pin:
system('clear')
print 'U Pin Found: %d'%pin;sleep(0.7)
for i in range(3):
exit()
def Down():
global Pin
pins = xrange(10000)
for pin in reversed(pins):
system('clear')
print pin
if pin == Pin:
system('clear')
print 'D Pin Found: %d'%pin;sleep(0.7)
exit()
def Random():
global Pin
while True:
pins = randint(1111,10000)
print pins
if pins == Pin:
system('clear')
print 'R Pin Found: %d'%pins;sleep(0.7)
exit()
Task1 = Thread(target=Up,args=())
Task2 = Thread(target=Down,args=())
Task3 = Thread(target=Random,args=())
Task1.start()
Task2.start()
Task3.start()