Skip to content

Instantly share code, notes, and snippets.

@R3DHULK
Created March 8, 2023 18:40
Show Gist options
  • Save R3DHULK/e637a527a050ef017cc074dfa363c620 to your computer and use it in GitHub Desktop.
Save R3DHULK/e637a527a050ef017cc074dfa363c620 to your computer and use it in GitHub Desktop.
Text Based Simon Says Written In Python
import random
import time
def simon_says():
# Define the colors
colors = ["red", "green", "blue", "yellow"]
# Keep track of the sequence
sequence = []
while True:
# Add a new color to the sequence
sequence.append(random.choice(colors))
# Show the sequence
print("Simon says:", end=" ")
for color in sequence:
print(color, end=" ", flush=True)
time.sleep(1)
print()
# Ask the user to repeat the sequence
print("Repeat the sequence:")
for color in sequence:
guess = input()
if guess != color:
print("Game over!")
return
print("Correct!")
if __name__ == "__main__":
simon_says()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment