repl.it
@1Ethan/

GuessThePassword

Python

No description

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import time
import random

count = 0
secure_random = random.SystemRandom()
randomwords = ["Hello","Password","Passcode","PC","RepL.it","Run","Python","default","design","zombie"]
securepassword = random.choice(randomwords)

print("---------------------------------------------")
time.sleep(1.5)
print("Welcome to guess the password! ")
time.sleep(1.5)
print("You will have three attempts. ")
time.sleep(1.5)
print("You will be given a list of random words, the password is one of them.")
time.sleep(1.5)
print("---------------------------------------------")
time.sleep(1.5)
print("All the random words are",randomwords,"")
time.sleep(1.5)
throwaway = input("Ready to start? (Y or N) ")
time.sleep(1.5)
print("---------------------------------------------")


if throwaway == "Yes" or throwaway == "yes" or throwaway == "Y":
  attempt = input("What is your first guess? ")
  if attempt == securepassword:
    print("Well done, you guessed the password correctly, first time! ")
    time.sleep(1.5)
    print("Thanks for playing, screenshot this to prove you won first time! ")
    time.sleep(2)
    print("---------------------------------------------")
    raise Exception("Program finished, you won first time! ")
  else:
    print("Incorrect! 2 attempts left! ")
    count = count+1
elif throwaway == "No" or throwaway == "no" or throwaway =="N":
  print("You aren't ready..? Program terminating then..! ")
  print("---------------------------------------------")
  raise Exception("You can't take the heat 'huh? ")
else:
  print("We didn't recognise that input, sorry! ")
  print("---------------------------------------------")
  raise Exception("Program terminating, we didn't quite get that input. ")

if count == 3:
  print("You have had all your attempts, restart this program to try again! ")
  print("---------------------------------------------")
  raise Exception("Game ended, you have reached your attempts.")
elif count == 1:
  print("---------------------------------------------")
  attempt = input("What is your second guess? ")
  if attempt == securepassword:
    print("Well done, you guessed the password correctly, second try! ")
    time.sleep(1.5)
    print("---------------------------------------------")
    raise Exception("Game ended, you have have won second try!")
  else:
    print("Wrong. 1 attempt left!")
    print("---------------------------------------------")
    count = count+1

if count == 2:
  print("You have one attempt left. ")
  attempt = input("What is your FINAL guess? ")
  if attempt == securepassword:
    time.sleep(1)
    print("---------------------------------------------")
    time.sleep(1)
    print("Well done, you have guessed the password on your final try! ")
    raise Exception("Game finished, you have won on your last attempt. ")
  else:
    print("---------------------------------------------")
    print("You didn't guess the password!")
    time.sleep(1.5)
    print("The password was",securepassword,"! ")
    time.sleep(1.5)
    print("---------------------------------------------")
    time.sleep(1)
    raise Exception("Program has finished, thanks for playing! ")

Fetching token
?