Skip to content

Commit ee92291

Browse files
author
Christian Bender
authored
Merge pull request TheAlgorithms#325 from cclauss/patch-5
Properly define raw_input() in Python 3
2 parents 2ca8d16 + bec160c commit ee92291

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

hashes/chaos_machine.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
from __future__ import print_function
33

44
try:
5-
raw_input
6-
input = raw_input
7-
except:
8-
pass
5+
input = raw_input # Python 2
6+
except NameError:
7+
pass # Python 3
98

109
# Chaos Machine (K, t, m)
1110
K = [0.33, 0.44, 0.55, 0.44, 0.33]; t = 3; m = 5
@@ -101,7 +100,7 @@ def reset():
101100
inp = ""
102101

103102
# Pulling Data (Output)
104-
while inp != "e" and inp != "E":
103+
while inp in ("e", "E"):
105104
print("%s" % format(pull(), '#04x'))
106105
print(buffer_space); print(params_space)
107-
inp = input("(e)exit? ")
106+
inp = input("(e)exit? ").strip()

0 commit comments

Comments
 (0)