├── threecupmonte game.py └── README.md /threecupmonte game.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | 4 | from random import shuffle 5 | 6 | # Function to shuffle the list 7 | def shuffle_list(mylist): 8 | shuffle(mylist) # Shuffles the list in place 9 | return mylist # You can return mylist for clarity, but shuffle modifies it in place 10 | 11 | # Function to get player's guess 12 | def player_guess(): 13 | guess = "" 14 | while guess not in ['0', '1', '2']: 15 | guess = input('PICK A NUMBER: 0, 1, OR 2: ') 16 | return int(guess) 17 | 18 | # Function to check the guess 19 | def check_list(game_list, guess): 20 | if game_list[guess] == 'O': 21 | print("Correct! 👏") 22 | else: 23 | print("Wrong guess! 😢") 24 | print(game_list) 25 | 26 | # Main game logic 27 | if __name__ == "__main__": 28 | # Initial list 29 | game_list = [' ', 'O', ' '] 30 | 31 | # Shuffle list 32 | mixedup_list = shuffle_list(game_list) 33 | 34 | # Get user's guess 35 | guess = player_guess() 36 | 37 | # Check the guess 38 | check_list(mixedup_list, guess) 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Three-cup-montee-game 2 | 3 | # Shuffle and Guess Game 🎲 4 | 5 | A fun and interactive Python command-line game where you try to find the hidden "O" in a shuffled list. Perfect for beginners learning Python basics like list manipulation, user input, and randomness. 6 | 7 | --- 8 | 9 | ## Features 10 | - **Interactive Gameplay**: Players guess the position of the "O". 11 | - **Randomized Outcomes**: The list is shuffled each time, keeping the game exciting. 12 | - **Beginner-Friendly**: A simple and educational project for learning Python. 13 | 14 | --- 15 | 16 | ## How to Play 17 | 1. Run the script using Python 3: 18 | ```bash 19 | python threecupmonte game.py 20 | 21 | 2. The program shuffles a list: [' ', 'O', ' ']. 22 | 3. You will be prompted to guess the position of the "O" by entering 0, 1, or 2. 23 | 4. The program evaluates your guess and provides feedback: 24 | Correct Guess: Prints "Correct! 👏" 25 | Incorrect Guess: Prints "Wrong guess! 😢" 26 | 5. The shuffled list is revealed to show the correct position. 27 | 28 | 29 | Code Overview 30 | 1. shuffle_list(mylist): Shuffles a given list randomly. 31 | 2. player_guess(): Ensures user input is valid and returns the guessed position. 32 | 3. check_list(game_list, guess): Compares the user's guess with the shuffled list and displays results. 33 | 4. Main Game: Combines all the functions to run the game interactively. 34 | 35 | Customization 36 | Change the symbols in the list to suit your preference (e.g., replace 'O' with 'X'). 37 | Add a scoring system or implement multiple rounds. 38 | Expand the game with more advanced Python concepts like GUIs using Tkinter. 39 | 40 | 41 | Requirements 42 | Python 3.6 or later installed on your system. 43 | 44 | 45 | License 46 | This project is licensed under the MIT License. Feel free to use, modify, and share it. 47 | 48 | Enjoy playing and learning! 🚀 49 | --------------------------------------------------------------------------------