repl.it
@KianAlford/

guessing game

Python

guess

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import random

ran_num = random.randint(1 , 9)
guess_count = 0
random_continue = random.randint(1 , 2)

a = 1

while a == 1:

  guess = input('what is your guess: ')

  if guess == str(ran_num):
    print('that is correct!')
    guess_count += 1
    print('your guess count was: ' + str(guess_count))
    play_again = input('would you like to play again? ')

    if play_again == 'no':
      print('ok goodbye.')
      break

    elif play_again == 'yes':
      print('ok!')
      guess_count = 0

  elif guess < str(ran_num) or guess > str(ran_num):
    guess_count += 1
    print('that is not correct.')

    if random_continue == random.randint(1 , 2):
      Continue = input('Would you like to continue? ')
      
      if Continue == 'yes':
        continue

      elif Continue == 'no':
        print('Ok thanks for playing. the number was: ' + str(ran_num))
        print('Your guess count was: ' + str(guess_count))
        break
Fetching token
?