Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 154e536

Browse files
Merge pull request avinashkranjan#2907 from avinashkranjan/deepsource-transform-a4971171
format code with autopep8
2 parents 838b910 + 6686db7 commit 154e536

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

‎Die Roll Guessing Game/dice_roll_game.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,28 @@
3939
'| O O |',
4040
' ------- ']
4141

42-
42+
4343
]
4444

45+
4546
def roll_dice():
4647
return random.randint(1, 6)
4748

49+
4850
def print_dice(dice_value):
4951
for line in dice_faces[dice_value - 1]:
5052
print(line)
5153

54+
5255
def print_two_dice(dice_values):
5356
for i in range(5):
54-
print(dice_faces[dice_values[0] - 1][i], " ", dice_faces[dice_values[1] - 1][i])
57+
print(dice_faces[dice_values[0] - 1][i],
58+
" ", dice_faces[dice_values[1] - 1][i])
59+
5560

5661
def play_game():
5762
level = input("Select level (easy/difficult): ").lower()
58-
63+
5964
if level == "easy":
6065
actual_roll = roll_dice()
6166
print("Guess the outcome of a dice roll (1 to 6).")
@@ -66,18 +71,18 @@ def play_game():
6671
else:
6772
print("Invalid level choice.")
6873
return
69-
74+
7075
try:
7176
user_guess = int(input())
7277
if (1 <= user_guess <= 6 and level == "easy") or (2 <= user_guess <= 12 and level == "difficult"):
7378
print("\nRolling the dice...")
74-
time.sleep(1)
75-
79+
time.sleep(1)
80+
7681
if level == "difficult":
7782
print_two_dice(actual_rolls)
7883
else:
7984
print_dice(actual_roll)
80-
85+
8186
if user_guess == actual_roll:
8287
print("Congratulations! You win!")
8388
else:
@@ -86,7 +91,8 @@ def play_game():
8691
print("Invalid guess. Please enter a valid number.")
8792
except ValueError:
8893
print("Invalid input. Please enter a number.")
89-
94+
95+
9096
if __name__ == "__main__":
9197
print("Welcome to the Dice Roll Guessing Game!")
9298
while True:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /