I need Python to check if it's connected to the internet every time a loop runs. I need the output to be in a variable, a yes or no thing.
This is the code I tried but it never repeats in a loop.
try:
socket.create_connection(("www.swisscows.com",80))
b= [1]
pass
except OSError:
b= [0]
pass