@@ -36,6 +36,20 @@ def show_countdown():
3636 time .sleep (1 )
3737 clear_screen ()
3838
39+ def get_difficulty ():
40+ print ("🎯 Select Difficulty" )
41+ print ("1. Easy (5 sec)" )
42+ print ("2. Medium (4 sec)" )
43+ print ("3. Hard (2 sec)" )
44+
45+ choice = input ("Enter choice (1/2/3): " ).strip ()
46+
47+ if choice == "1" :
48+ return 5
49+ elif choice == "3" :
50+ return 2
51+ else :
52+ return 4
3953
4054def play_game ():
4155 score = 0
@@ -45,6 +59,9 @@ def play_game():
4559 print ("🎮 Welcome to Emoji Memory Game!" )
4660 print (f"🏅 High Score: { high_score } \n " )
4761
62+ # Added difficulty mode
63+ display_time = get_difficulty ()
64+
4865 show_countdown ()
4966
5067 while True :
@@ -53,10 +70,15 @@ def play_game():
5370 print ("🧠 MEMORIZE THESE EMOJIS:" )
5471 print (" " .join (sequence ))
5572
56- time .sleep (4 )
73+ # difficulty-based timing
74+ time .sleep (display_time )
5775 clear_screen ()
5876
59- user_input = input ("Type the emojis in order:\n > " ).split ()
77+ # Improved input validation
78+ user_input = input ("Type the emojis in order:\n > " ).strip ().split ()
79+
80+ # normalize input
81+ user_input = [emoji .strip () for emoji in user_input ]
6082
6183 if not user_input :
6284 print ("⚠️ Empty input detected!" )
@@ -84,4 +106,12 @@ def play_game():
84106
85107
86108if __name__ == "__main__" :
87- play_game ()
109+ while True :
110+ play_game ()
111+
112+ # Replay option
113+ choice = input ("\n Play again? (y/n): " ).strip ().lower ()
114+
115+ if choice != "y" :
116+ print ("👋 Thanks for playing!" )
117+ break
0 commit comments