snake water gun game in python

# Snake water gun game in python 
'''
Snake vs. Water: Snake drinks the water hence wins.
Water vs. Gun: The gun will drown in water, hence a point for water
Gun vs. Snake: Gun will kill the snake and win.
In situations where both players choose the same object, the result will be a draw.

'''
import random
user = 0
computer = 0
turns = 0
while (turns<10):
    a = ['Snake','Water','Gun']
    pc = random.choice(a)
    print(pc)
    turns +=1
    dic = {1:'Snake',2:'Water',3:'Gun'}
    b = int(input('1.Snake,2.Water,3.Gun'))
    if b in dic:
        print(dic[b])
        if pc == 'Snake':
            if dic[b] == 'Snake':
                print('its tie')
            elif dic[b] == 'Water':
                print('PC wins')
                computer +=1
            elif dic[b] == 'Gun':
                print('user wins')
                user+=1
                
        elif pc == 'Water':
            if dic[b] == 'Snake':
                print('user wins')
                user+=1
            elif dic[b] == 'Water':
                print('its tie')
            elif dic[b] == 'Gun':
                print('computer wins')
                computer +=1
         elif pc == 'Gun':
            if dic[b] == 'Snake':
                print('PC wins')
                computer+=1
            elif dic[b] == 'Water':
                print('user wins')
                user+=1
            elif dic[b] == 'Gun':
                print('its a tie')
    else:
        print('retry entry')

print('Game over', 'user:',user,'computer:',computer)

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source