Can’t exit while loop with break

  Kiến thức lập trình

This is my current code and I want it so that when the letter q is inputted the “while True” is skipped and goes to the sys.exit() cmd, however it just returns at the beginning of the loop.

import random
import sys

print ('ROCK, PAPER SCISSORS')
while True:
    wins = 0
    loss = 0
    ties = 0
    print (str(wins) + ' Wins, ' + str(loss) + ' Losses, ' + str(ties) + ' Ties')
    print ('Enter your move: (r)ock (p)aper (s)cissors or (q)uit')
    move = input()
    if input == 'q':
        print ('Quitted Game.')
        break
sys.exit()

This is what results in the terminal

0 Wins, 0 Losses, 0 Ties
Enter your move: (r)ock (p)aper (s)cissors or (q)uit
q
0 Wins, 0 Losses, 0 Ties
Enter your move: (r)ock (p)aper (s)cissors or (q)uit

New contributor

Coder Jungle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT