Merge pull request #236 from Sayan97/patch-4

Update cyclesort.py
This commit is contained in:
Harshil 2018-01-07 13:26:29 +05:30 committed by GitHub
commit 335bc2e390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,7 +44,13 @@ def cycle_sort(array):
# Main Code starts here
user_input = input('Enter numbers separated by a comma:\n')
if __name__ == '__main__':
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
user_input = raw_input('Enter numbers separated by a comma:\n')
unsorted = [int(item) for item in user_input.split(',')]
n = len(unsorted)
cycle_sort(unsorted)