Why doesn't my game restart?

This is the place for queries that don't fit in any of the other categories.

Why doesn't my game restart?

Postby BlueBeachMonster » Sat Aug 02, 2014 8:54 pm

Pretty simple game to example the code I am using in my real game:
Code: Select all
#Rock Paper Scissors by Rocky-Road Studios
import random
choices=['rock', 'paper', 'scissors']
restart=True
bot=('Potatoe')
while restart==True:
    print('''Welcome to Rock Paper Scissors!
          ''')
    choice=input('''Rock, Paper or Scissors?
''')
    bot=(random.choice(choices))
    print('You chose {}!'.format(choice))
    print('The bot chose {}!'.format(bot))
    print('Therefore:')
    if choice.lower()==bot.lower():
        print('Draw!')
       
    elif (choice.lower()==('rock')) and (bot.lower()==('paper')):
        print('You Loose! :(')

    elif (choice.lower()==('scissors')) and (bot.lower()==('rock')):
        print('You Loose! :(')

    elif (choice.lower()==('paper')) and (bot.lower()==('scissors')):
        print('You Loose! :(')

    elif (choice.lower()==('scissors')) and (bot.lower()==('paper')):
        print('You Won! :)')

    elif (choice.lower()==('rock')) and (bot.lower()==('scissors')):
        print('You Won! :)')

    elif (choice.lower()==('paper')) and (bot.lower()==('rock')):
        print('You Won! :)')
    else:
        print('Incorrect input, you entered: {}!'.format(choice))

    restartq=input('''Again? (Yes or No)
''')
    if restartq.lower()=='yes':
        restart=True
    elif restartq.lower()=='no':
        restart=False
        print('''
Thanks for playing!
''')
    else:
        print('Invalid input, we\'ll just asume you meant yes!')
        restart=True
    #Below is debug
    print('Restarting')
       
Last edited by BlueBeachMonster on Sat Aug 02, 2014 9:46 pm, edited 1 time in total.
BlueBeachMonster
 
Posts: 5
Joined: Fri Apr 04, 2014 8:33 pm

Re: Why doesn't my game restart?

Postby DrakeMagi » Sat Aug 02, 2014 9:31 pm

If block does not loop. It a logic expression.
Code: Select all
while restart: # == True is not needed
Linux: won't find windows here.
Linux: the choice of a GNU generation.
https://github.com/DrakeMagi
DrakeMagi
 
Posts: 111
Joined: Sun May 12, 2013 8:36 pm

Re: Why doesn't my game restart?

Postby BlueBeachMonster » Mon Aug 04, 2014 6:44 pm

DrakeMagi wrote:If block does not loop. It a logic expression.
Code: Select all
while restart: # == True is not needed

Thanks!
BlueBeachMonster
 
Posts: 5
Joined: Fri Apr 04, 2014 8:33 pm


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron