-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemory_game.py
62 lines (56 loc) · 1.77 KB
/
Memory_game.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
#Memory Game
import os
import time
count=1
def findAndPrintUncommonChars(str1, str2):
l1 = len(str1)
l2 = len(str2)
if l1!=l2:
print("Your input length does not match to the actual text lenghth")
else:
for i in range(0, l1):
if str1[i]!=str2[i]:
print("\nCharacter mismatch at position: ",i)
print("The actual character was '"+str1[i]+"' and you entered '"+str2[i]+"'")
def presskeytocontinue():
str4=input("\nPress any key to continue...")
if str4:
os.system('resume')
def clearscreen():
os.system('cls' if os.name == 'nt' else 'clear')
if __name__ == "__main__":
clearscreen()
str1="This is the red apple #"+str(count)
print("Please read the below message carefully\n")
print("Message -> "+str1+"\n")
print("The above text will appear for 5 seconds")
time.sleep(5)
clearscreen()
str2=input("Enter the text appeared before : ")
if len(str2)<20:
print("Sorry your input does not match to the input length constraint")
print("Your input contains : ",len(str2)," characters")
print("Your input should contain atleast 20 characters.")
else:
while str1!=str2:
count=count+1
print("\nSorry!! Wrong input\n")
findAndPrintUncommonChars(str1,str2)
presskeytocontinue()
clearscreen()
if count<=3:
print("Please see the read Message carefully\n")
str1="This is the red apple #"+str(count)
print("Message -> "+str1+"\n")
print("The above text will appear for 5 seconds")
time.sleep(5)
clearscreen()
str2=input("Enter the text appeared before : ")
else:
print("Oopss!! Your attempt is over...\n\nBetter luck next time...")
break
else:
print("\nCorrect answer\n")
str3=input("\nPress enter any key to exit ")
if str3:
os.system('exit')