python practice

Some code I wrote while practicing python one day. A couple of the problems had built in solutions that I was not aware of so I basically coded the solution the hard way. In a way that’s cool because it shows that I could have written that actual function that’s included in python to create the “shortcut” but it also shows that I did not know the easy way to do it.

import requests
import json 

r = requests.get("")
d = r.json() 

ip_prefix_list = d.get("prefixes")

for i in ip_prefix_list:
   ip = i.get("ip_prefix")
   print (ip)

# Cipher should eliminate capitalization, spaces & punctuation for maximum effectivness 
import string

def caesar():
    message = input("\nPlease input your message.\n").replace(" ","").lower().strip(string.punctuation)
    shift = int(input("What is the shift desired for the encoding?\n "))
    if (shift % 26 == 0):
        return("There can be no shift if divisible by 26")
    # decode option is simple math - inverse operations
    if "e" not in input("\nType 'e' or 'E' to encode, anything else will decode\n"):
        shift = len(string.ascii_letters) - shift
    alphabet = string.ascii_letters.lower()
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    table = str.maketrans(alphabet, shifted_alphabet)
    return message.translate(table)

if __name__ == '__main__':

import string

print string.ascii_lowercase[::-1]

import string

my_array = []
array = list(string.ascii_lowercase)

while array:

reverse_string = "".join(my_array)

print reverse_string

seq = raw_input("Enter a word please").lower()
if seq == seq[::-1]:
    print "yes, %s is a palindrome word" % (seq)
    print "sorry, '%s' 'isn\'t a palindrome word" % (seq)

# Test for palindrome - Rats live on no evil star

def palindrome(message):
    while message:
        if message[0] == message[-1]:

    if not message:
        print("Your string IS a palindrome")
        print("Your string IS NOT a palindrome")

if __name__ == '__main__':

    palindrome(list(input("\nInput string to test palindrome\n").replace(" ", "").lower()))