Skip to content

Commit 957045e

Browse files
style: format code with autopep8
Format code with autopep8 This commit fixes the style issues introduced in 2300867 according to the output from Autopep8. Details: https://app.deepsource.com/gh/avinashkranjan/Amazing-Python-Scripts/transform/e77ce59b-6f1d-4841-b0d6-1b65f1011903/
1 parent 2300867 commit 957045e

File tree

1 file changed

+74
-74
lines changed

1 file changed

+74
-74
lines changed

Rock-paper-scissors/game.py

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,82 @@
11
import random
22

33
print('Winning rules of the game ROCK PAPER SCISSORS are :\n'
4-
+ "Rock vs Paper -> Paper wins \n"
5-
+ "Rock vs Scissors -> Rock wins \n"
6-
+ "Paper vs Scissors -> Scissor wins \n")
4+
+ "Rock vs Paper -> Paper wins \n"
5+
+ "Rock vs Scissors -> Rock wins \n"
6+
+ "Paper vs Scissors -> Scissor wins \n")
77

88
while True:
9-
print("Enter your choice \n 1 - Rock \n 2 - Paper \n 3 - Scissors \n")
10-
11-
choice = int(input("Enter your choice: "))
12-
13-
# looping until the user enters a valid input
14-
while choice > 3 or choice < 1:
15-
choice = int(input('Enter a valid choice please: '))
16-
17-
# initialize the value of choice_name variable
18-
# corresponding to the choice value
19-
if choice == 1:
20-
choice_name = 'Rock'
21-
elif choice == 2:
22-
choice_name = 'Paper'
23-
else:
24-
choice_name = 'Scissors'
25-
26-
# print the user's choice
27-
print('User choice is:', choice_name)
28-
print('Now it\'s the Computer\'s Turn....')
29-
30-
# Computer chooses randomly any number
31-
# among 1, 2, and 3 using randint method
32-
comp_choice = random.randint(1, 3)
33-
34-
# looping until comp_choice value
35-
# is equal to the choice value
36-
while comp_choice == choice:
37-
comp_choice = random.randint(1, 3)
38-
39-
# initialize the value of comp_choice_name
40-
# variable corresponding to the choice value
41-
if comp_choice == 1:
42-
comp_choice_name = 'Rock'
43-
elif comp_choice == 2:
44-
comp_choice_name = 'Paper'
45-
else:
46-
comp_choice_name = 'Scissors'
47-
48-
print("Computer choice is:", comp_choice_name)
49-
print(choice_name, 'Vs', comp_choice_name)
50-
51-
# we need to check for a draw
52-
if choice == comp_choice:
53-
print('It\'s a Draw', end="")
54-
result = "DRAW"
55-
56-
# condition for winning
57-
if ((choice == 1 and comp_choice == 2) or
58-
(choice == 2 and comp_choice == 3) or
59-
(choice == 3 and comp_choice == 1)):
60-
print('Computer wins =>', end="")
61-
result = 'Computer'
62-
else:
63-
print('You win =>', end="")
64-
result = 'User'
65-
66-
# Printing either user or computer wins or draw
67-
if result == 'DRAW':
68-
print("<== It's a tie ==>")
69-
elif result == 'User':
70-
print("<== You win ==>")
71-
else:
72-
print("<== Computer wins ==>")
73-
74-
print("Do you want to play again? (Y/N)")
75-
76-
# if user input n or N, then the condition is True
77-
ans = input().lower()
78-
if ans == 'n':
79-
break
9+
print("Enter your choice \n 1 - Rock \n 2 - Paper \n 3 - Scissors \n")
10+
11+
choice = int(input("Enter your choice: "))
12+
13+
# looping until the user enters a valid input
14+
while choice > 3 or choice < 1:
15+
choice = int(input('Enter a valid choice please: '))
16+
17+
# initialize the value of choice_name variable
18+
# corresponding to the choice value
19+
if choice == 1:
20+
choice_name = 'Rock'
21+
elif choice == 2:
22+
choice_name = 'Paper'
23+
else:
24+
choice_name = 'Scissors'
25+
26+
# print the user's choice
27+
print('User choice is:', choice_name)
28+
print('Now it\'s the Computer\'s Turn....')
29+
30+
# Computer chooses randomly any number
31+
# among 1, 2, and 3 using randint method
32+
comp_choice = random.randint(1, 3)
33+
34+
# looping until comp_choice value
35+
# is equal to the choice value
36+
while comp_choice == choice:
37+
comp_choice = random.randint(1, 3)
38+
39+
# initialize the value of comp_choice_name
40+
# variable corresponding to the choice value
41+
if comp_choice == 1:
42+
comp_choice_name = 'Rock'
43+
elif comp_choice == 2:
44+
comp_choice_name = 'Paper'
45+
else:
46+
comp_choice_name = 'Scissors'
47+
48+
print("Computer choice is:", comp_choice_name)
49+
print(choice_name, 'Vs', comp_choice_name)
50+
51+
# we need to check for a draw
52+
if choice == comp_choice:
53+
print('It\'s a Draw', end="")
54+
result = "DRAW"
55+
56+
# condition for winning
57+
if ((choice == 1 and comp_choice == 2) or
58+
(choice == 2 and comp_choice == 3) or
59+
(choice == 3 and comp_choice == 1)):
60+
print('Computer wins =>', end="")
61+
result = 'Computer'
62+
else:
63+
print('You win =>', end="")
64+
result = 'User'
65+
66+
# Printing either user or computer wins or draw
67+
if result == 'DRAW':
68+
print("<== It's a tie ==>")
69+
elif result == 'User':
70+
print("<== You win ==>")
71+
else:
72+
print("<== Computer wins ==>")
73+
74+
print("Do you want to play again? (Y/N)")
75+
76+
# if user input n or N, then the condition is True
77+
ans = input().lower()
78+
if ans == 'n':
79+
break
8080

8181
# after coming out of the while loop
8282
# we print thanks for playing

0 commit comments

Comments
 (0)