#!/usr/bin/python3
# coding=utf-8
# La première ligne sert pour python (et ipython) 2, qui n'aiment pas
# les caractères non ASCII.

# Dans ipython :
# run seance5.py

def zip (a, b):
    r = []
    for i in range (len (a)):
        r.append ((a[i], b[i]))
    return r

def unzip (a):
    r1 = []
    r2 = []
    for e in a:
        r1.append (e[0])
        r2.append (e[1])
    return r1, r2

def take (how_many, list):
    r = []
    for i in range (how_many):
        r.append (list[i])
    return r

def donttake (how_many_to_skip, list):
    r = []
    for i in range (how_many_to_skip, len (list)):
        r.append (list[i])
    return r

def max (a, b):
    if a > b:
        return a
    else:
        return b

def max_length_in (list_of_strings):
    r = len (list_of_strings[0])
    for s in list_of_strings:
        r = max (r, len (s))
    return r

def make_asterisk_line2 (width):
    return '*' * width

def make_asterisk_line (width):
    s = ''
    for i in range (width):
        s = s + '*'
    return s

def print_asterisk_line (width):
    print (make_asterisk_line (width))

def print_block (list_of_strings):
    max_string_witdh = max_length_in (list_of_strings)
    frame_width = max_string_witdh + 4 # asterisk, space, space, asterisk
    print_asterisk_line (frame_width)
    for s in list_of_strings:
        spaces = ' ' * (max_string_witdh - len (s));
        print ("* " + s + spaces + " *")
        # print "* " + s + (' ' * (max_string_witdh - len (s))) + " *"
    print_asterisk_line (frame_width)

# print_block (['Python', 'is', 'a', 'beautiful', 'language,', 'more', 'or', 'less'])

# Méthodes sur les chaînes: s.lower (),  s.upper () : elles renvoeyent les chaînes
# toutes en minuscule ou en majuscule.

# English is translated to Pig Latin by taking the first letter of every word,
# moving it to the end of the word and adding ‘ay’.
def pigify_word (word):
    s = without_first_letters (1, word) + word[0].lower () + 'ay'
    return s[0].upper () + without_first_letters (1, s);

def without_first_letters (how_many_to_skip, word):
    s = ""
    for i in range (how_many_to_skip, len (word)):
        s = s + word[i]
    return s

