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)

import string

message = raw_input("\nPlease input your message.\n")
shift = int(raw_input("What is the shift? "))
codec = raw_input("\nPress 1 to encode, anything else will decode\n")

# decode option is simple math - inverse operations
if codec != '1':
    shift = 52 - shift

def caesar(message, shift):
    alphabet = string.ascii_letters
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    table = string.maketrans(alphabet, shifted_alphabet)
    return message.translate(table)

caesar(message, shift)

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)

array = list(raw_input("\nPlease input string to test for plaindrome condition.\n").lower())

while len(array) > 1:
    if array[0] == array[-1]:

if len(array) == 0 or len(array) == 1:
    print "Your string IS a palindrom"
    print "Your string IS NOT a plaindrom"