CopyPastor

Detecting plagiarism made easy.

Score: 0.8462114930152893; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-08-21
by Hamza Lachi

Original Post

Original - Posted on 2019-08-21
by fulvio



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Your line 42 is not in **2nd** **`while loop`** so that's why you getting an error make sure it will in while loop here is your line:
if play_again == 'exit': break else: continue

**you can copy this code:**
from random import randint def guessing_game(): print('Welcome to the Guessing Game') print('If you would like to exit, just type exit') while True: num = randint(1,9) guesses = [] while True: try: guess = int(input('Please guess a number between 1 and 9: ')) except: print('Please enter a numerical value') continue else: if guess < 1 or guess > 9: print('OUT OF RANGE') continue else: if guess == num: print(f'Congratulations, you guessed the correct number in {len(guesses)} guesses') break else: if guess > num: print('TOO HIGH') guesses.append(guess) continue else: print('TOO LOW') guesses.append(guess) continue play_again = input('Enter exit to stop playing: ') if play_again == 'exit': break else: continue

Check the indentation of the last few lines and make sure they're inside the `while` loop and it will work.
from random import randint def guessing_game(): print('Welcome to the Guessing Game') print('If you would like to exit, just type exit') while True: num = randint(1,9) guesses = [] while True: try: guess = int(input('Please guess a number between 1 and 9: ')) except: print('Please enter a numerical value') continue else: if guess < 1 or guess > 9: print('OUT OF RANGE') continue else: if guess == num: print(f'Congratulations, you guessed the correct number in {len(guesses)} guesses') break else: if guess > num: print('TOO HIGH') guesses.append(guess) continue else: print('TOO LOW') guesses.append(guess) continue play_again = input('Enter exit to stop playing: ') if play_again == 'exit': break else: continue Repl: https://repl.it/repls/TurbulentImpeccableObjectdatabase

        
Present in both answers; Present only in the new answer; Present only in the old answer;