Suggestions
Opened this issue · 0 comments
milliorn commented
leapyearchecker.py -> https://stackoverflow.com/a/11622584/11986604
random password generator.py -> This line of code can replace string
and you just change the values to use whatever codes you want.
alphabet = list(map(chr, range(33, 123)))
import random
alphabet = list(map(chr, range(33, 123)))
def generate_password():
password_len = int(input("Enter password length:"))
random.shuffle(alphabet)
password = []
for x in range(password_len):
password.append(random.choice(alphabet))
random.shuffle(password)
password = "".join(password)
print(password)
generate_password()
site connectivity checker.py
import urllib.request as urlib
def site_checker(url):
print("Checking connectivity ")
response = None
try:
response = urlib.urlopen(url)
print("Connected to", url, "successfully")
print("The response code was: ", response.getcode())
except Exception as ex:
print(ex)
finally:
if response is not None:
response.close()
input_url = input("Enter the url you wish to check connectivity: ")
site_checker(input_url)
This will make sure to give an error code if one pops up. Also, it's important to close connections when we are done.