1import threading
2import time
3
4def infiniteloop1():
5 while True:
6 print('Loop 1')
7 time.sleep(1)
8
9def infiniteloop2():
10 while True:
11 print('Loop 2')
12 time.sleep(1)
13
14thread1 = threading.Thread(target=infiniteloop1)
15thread1.start()
16
17thread2 = threading.Thread(target=infiniteloop2)
18thread2.start()
19
1# You can use threading
2import threading # python 3.9.1
3
4def Task_One():
5 while True:
6 print('Rawr')
7
8def Task_Two():
9 while True:
10 print('de.cxl ig <3')
11
12# Use variable or instantly start thread
13
14threading.Thread(target=Task_One).start() # Task_One()
15threading.Thread(target=Task_Two).start() # Task_Two()
1
2# ------------- For loop using 2 items of a list --------------- #
3
4# This code is trying to find if a point belongs between
5# the interval of pairing points of a list:
6
7mylist = [117, 202, 287, 372, 457, 542]
8point = 490
9# 117 < x < 202 ?
10# 287 < x < 372 ?
11# 457 < x < 542 ?
12
13for i, j in zip(mylist[::2], mylist[1::2]):
14 if i < point < j:
15 print ("This point exists between: ", i, " - ", j)
16 break
17
18
19