Skip to content

Commit 335bc2e

Browse files
authored
Merge pull request #236 from Sayan97/patch-4
Update cyclesort.py
2 parents 1f41a31 + 5d4471d commit 335bc2e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sorts/cyclesort.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ def cycle_sort(array):
4444

4545

4646
# Main Code starts here
47-
user_input = input('Enter numbers separated by a comma:\n')
47+
if __name__ == '__main__':
48+
try:
49+
raw_input # Python 2
50+
except NameError:
51+
raw_input = input # Python 3
52+
53+
user_input = raw_input('Enter numbers separated by a comma:\n')
4854
unsorted = [int(item) for item in user_input.split(',')]
4955
n = len(unsorted)
5056
cycle_sort(unsorted)

0 commit comments

Comments
 (0)