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 4563e05

Browse files
Merge pull request #15 from cclauss/modernize-Python-2-codes
Use print() function in both Python 2 and Python 3
2 parents f799884 + f30d46a commit 4563e05

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

‎python-exercises/game_5.py‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
from __future__ import print_function
12
import random
3+
4+
try:
5+
input = raw_input # Python 2
6+
except NameError:
7+
pass # Python 3
8+
29
min = 1
310
max = 6
411

512
roll_again = "yes"
613

7-
while roll_again =="yes"orroll_again=="y":
8-
print"Rolling the dices..."
9-
print"The values are...."
10-
printrandom.randint(min, max)
11-
printrandom.randint(min, max)
14+
while roll_again in ("yes", "y"):
15+
print("Rolling the dices...")
16+
print("The values are....")
17+
print(random.randint(min, max))
18+
print(random.randint(min, max))
1219

13-
roll_again = raw_input("Roll the dices again?")
20+
roll_again = input("Roll the dices again?").strip().lower()

0 commit comments

Comments
(0)

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