I need to ask the user if they would like to play a game, if the answer is y then the program will then ask you what game you want to play, if the user enters n or even enters they will be asked again till they enter y.
Right now I have the while loop accepting any answer. Anyone able to see what I'm missing or doing wrong?
playAGame = 'y'
while playAGame == 'y':
playAGame = raw_input('Would you like to play a game? (y/n)? ')
doAnother = 'y'
while doAnother == 'y':
print 'Chess'
print 'Tic Tac Toe'
print 'Tetris'
print 'Count'
print
print 'Global Thermonuclear War'
game = raw_input('Pick a game: ').lower()
if game == 'chess':
webbrowser.open_new("http://www.pygame.org/tags/chess")
break
elif game == 'tic tac toe':
webbrowser.open_new("http://www.pygame.org/tags/tictactoe")
break
elif game == 'tetris':
webbrowser.open_new("http://www.pygame.org/project-Clone+of+Tetris-2125-.html")
break
elif game == 'thermonuclear':
print "\nWouldn't you perfer a good game of chess?\n"
break
elif game == 'count':
maxNumber = input('How High? ')
for maxNumber in range(maxNumber):
print maxNumber
break
else:
print '\nI did not understand that!\n'
break
# Ask user if they want to do another
doAnother = raw_input('Do another (y/n)? ')
print '\nThanks for playing!'
print '\nGood Bye!'
playAGame = 'y'; if playAGame == 'y':?! Also, note that you only ask the user if they want to play again if they playedcount.isPlaying = Trueat the start and set it to false when you expect to quit. Or just use a break statement to exit the loop.