print  "Counting forward:\n";
for i in range(10):
    print  i ,
print  "\n\nCounting backward:\n";
for i in range(1,10,-1):
    print  i,
print  "\n\nCounting by fives:\n";
for i in range(0,51,5):
    print  i,
    
print  "\n\nCounting with null statements:\n";
count = 0;
while (  count < 10 ):
    print  count ,
    count += 1
print  "\n\nCounting with nested for loops:\n";
ROWS = 5;
COLUMNS = 3;
for i in range(ROWS):
    for j in range(COLUMNS):
        print  i , "," , j ,
word1 = "Game";
word2 ="Over"
word3 = '!'
phrase = word1 + " " + word2 + word3;
print  "The phrase is: " , phrase , "\n";
print  "The phrase has " , len(phrase) , " characters in it.\n";
print  "The character at position 0 is: " , phrase[0] , "\n\n";
print  "Changing the character at position 0.\n";
#phrase[0] = 'L';
print  "The phrase is now: " , phrase , "\n"
for i in range(len(phrase)):
    print  "Character at position " , i , " is: " , phrase[i] 
print  "\nThe sequence 'Over' begins at location ";
print  phrase.find("Over") 
if ("eggplant" not in phrase):
    print  "'eggplant' is not in the phrase.\n\n";
# Python does not support string erase function.
#phrase.erase(4, 5); 
print  "The phrase is now: " , phrase 
#phrase.erase(4);
print  "The phrase is now: " , phrase 
#phrase.erase();
print  "The phrase is now: " , phrase 
if (phrase==''):
    print  "\nThe phrase is no more.\n";
MAX_ITEMS = 10;
inventory = [];
inventory.append("sword")
inventory.append("armor")
inventory.append("shield")
print "Your items:\n";
for i in range(len(inventory)):
    print inventory[i]
print "\nYou trade your sword for a battle axe.";
inventory[0] = "battle axe";
print "\nYour items:\n";
for i in range(len(inventory)):
    print inventory[i]
print "\nThe item name '" , inventory[0] , "' has ",
print len(inventory[0]) , " letters in it.\n";
print "\nYou find a healing potion.";
if (len(inventory) < MAX_ITEMS):
    inventory.append("healing potion")
else:
    print "You have too many items and can't carry another.";
print "\nYour items:\n";
for i in range(len(inventory)):
    print inventory[i]
ROWS = 3;
COLUMNS = 3;
board = [['O', 'X', 'O'],[' ', 'X', 'X'],['X', 'O', 'O']]
print "Here's the tic-tac-toe board:\n";
for i in range(ROWS):
    for j in range(COLUMNS):
        print board[i][j],
    print ''
print "\n'X' moves to the empty location.\n\n";
board[1][0] = 'X';
print "Now the tic-tac-toe board is:\n";
for i in range(ROWS):
    for j in range(COLUMNS):
        print board[i][j],
    print ''
print "\n'X' wins!";
fields = ['WORD', 'HINT', 'NUM_FIELDS']
NUM_WORDS = 5;
WORDS = [ ["wall", "Do you feel you're banging your head against something?"],
        ["glasses", "These might help you see the answer."],
        ["labored", "Going slowly, is it?"],
        ["persistent", "Keep at it."],
        ["jumble", "It's what the game is all about."]]
class difficulty:
    EASY = 0
    MEDIUM = 1
    HARD = 2
    NUM_DIFF_LEVELS = 3
    
print  "There are " , difficulty.NUM_DIFF_LEVELS  ," difficulty levels."
import random
#srand(static_cast<unsigned int>(time(0)));
choice = (int(random.random() * 10) % NUM_WORDS);
theWord = WORDS[choice][0]; # word to guess
theHint = WORDS[choice][1]; # hint for word
jumble = theWord; # jumbled version of word
length = len(jumble)
for i in range(length):
    index1 = (int(random.random() * 10) % length);
    index2 = (int(random.random() * 10) % length);
    temp = list(jumble)
    temp[index1],temp[index2] = temp[index2],temp[index1]
    jumble = ''.join(temp)
print "\t\t\tWelcome to Word Jumble!\n\n";
print "Unscramble the letters to make a word.\n";
print "Enter 'hint' for a hint.\n";
print "Enter 'quit' to quit the game.\n\n";
print "The jumble is: " , jumble;
print  "Your guess: ";
guess = raw_input()
while ((guess != theWord) and (guess != "quit")):
    if (guess == "hint"):
        print theHint;
    else:
        print "Sorry, that's not it.";
    print "\n\nYour guess: ";
    guess = raw_input()
if (guess == theWord):
    print  "\nThat's it! You guessed it!\n";
print  "\nThanks for playing.\n";