mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Modernize Python 2 code to get ready for Python 3
This commit is contained in:
@ -51,11 +51,10 @@ class EditDistance:
|
||||
return self.__solveDP(len(A)-1, len(B)-1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if sys.version_info.major < 3:
|
||||
input_function = raw_input
|
||||
else:
|
||||
input_function = input
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
|
||||
solver = EditDistance()
|
||||
|
||||
@ -63,10 +62,10 @@ if __name__ == '__main__':
|
||||
print()
|
||||
|
||||
print("Enter the first string: ", end="")
|
||||
S1 = input_function()
|
||||
S1 = raw_input().strip()
|
||||
|
||||
print("Enter the second string: ", end="")
|
||||
S2 = input_function()
|
||||
S2 = raw_input().strip()
|
||||
|
||||
print()
|
||||
print("The minimum Edit Distance is: %d" % (solver.solve(S1, S2)))
|
||||
|
Reference in New Issue
Block a user