Going to begining of program from end

March 8, 2011 at 09:30:30
Specs: Windows Xp and 7
Hello, I made a hangman game and was wondering how to loop it(if you type yes to play again then go to begining) else exit. Is there something close to a batch file goto command IE:
:A
echo hi
goto A

Here's what i have so far:

print ('Created by - That One Guy')
print ('There are no unwanted consequences')
print ('Enjoy')

import time
time.sleep (5)

import os
os.system("cls")


print ('Hello.')
import time
time.sleep (3)

print ('What is your name?')

myname = raw_input ()

import time
time.sleep (2)
import os
os.system("cls")

print ('Well, '+myname+', would you like to play a game of hangman with me?')
print ('Please type "yes" or "no"' )


game = raw_input ()

import time
time.sleep (3)

if game == ('no'):
print ('Ok, have a good day.');
import time
time.sleep (3)
import sys
sys.exit()

if game == ('yes'):
print ('Ok then. Please let me think of something')
print ('The letters A,E,I,O,U will already be used')
import time
time.sleep (3)

import random
import urllib

print 'Ok. I have one...'
animals = urllib.urlopen('http://davidbau.com/data/animals').read().split()
secret = random.choice(animals)
guesses = 'aeiou'
turns = 5

while turns > 0:
missed = 0
for letter in secret:
if letter in guesses:
print letter,
else:
print '_',
missed += 1

print

if missed == 0:
print 'You win!'
break

guess = raw_input('guess a letter: ')
guesses += guess

if guess not in secret:
turns -= 1
print 'Nope.'
print turns, 'more turns'
if turns < 5: print ' O '
if turns < 4: print ' \_|_/ '
if turns < 3: print ' | '
if turns < 2: print ' / \ '
if turns < 1: print ' d b '
if turns == 0:
print 'The answer is', secret
import time
time.sleep(5)

print ('Would you like to play again?')
again = raw_input


if again == ('no'):
print ('Ok. Have a good day then.')
import time
time.sleep (3)
import sys
sys.exit()

if again == ('yes'):
print ('Ok. Please wait one second.')
import time
time.sleep (3)


Thanks!


See More: Going to begining of program from end

Report •


#1
March 8, 2011 at 12:34:01
You need to use a "while" loop. Have a look at this article for a brief introduction, and read the Python documentation.

Report •

#2
March 8, 2011 at 18:16:20
Please excuse my stupidity but how could i implement that to go from the end back to the begining?

Thanks.


Report •

#3
March 8, 2011 at 23:45:27
I think that you need to read a good Python tutorial and work your way through it.

Report •

Related Solutions

#4
March 10, 2011 at 19:06:21
Probably. I tried to use the while statement and the only thing i got was an error message than a blue screen of death. Im scared now. 0.o

Report •

Ask Question