Skip to content

Instantly share code, notes, and snippets.

def print_table():
lookup = ['-', 'X', 'O']
for row in T:
print ' '.join([lookup[cell] for cell in row])
print
def move(player, row, column):
global next_player

Weather forecast

  1. Read the developer documentation of Forecast.io's API: https://developer.forecast.io/
  2. Register to get your developer key
  3. Use the Requests library and JSON to get a weekly forecast in degree Celsius (°C)
  4. Print the min and max temperature and the amount of rain forecasted for the next 7 days

JSON reading and writing

import time
def is_anagram(word1, word2):
# sorted converts to list by characters and sorts
return sorted(word1) == sorted(word2)
def reduce_list(mylist, reduce_factor):
new_list = list()
colors_list = ['blue', 'blue', 'green', 'yellow',
'blue', 'green', 'red']
sample_dict = {
'a': 1,
'b': 'hello',
'c': [1, 2, 3]
}