import sys import sorthelper import ast if len(sys.argv) != 2: print "Syntax: python process_sort.py [number1,number2,...]" numbers = ast.literal_eval(sys.argv[1]) print "Input List:", numbers print "Sorted List:", sorthelper.sortNumbers(numbers)
# coding: utf-8 # In[3]: #include standard modules import argparse import sys sys.path.append("/Users/elizabeth/Desktop/sorthelper.py") from sorthelper import sortNumbers #initialze the parser parser = argparse.ArgumentParser() parser.add_argument("a", nargs="*", type=list, help="Input a list.") #read arguments from the command line args = parser.parse_args() #get the sum myList = args.a #Sort the List sortNumbers(myList) #output results print("The sorted list: ", sortNumbers(myList)) # In[ ]:
### YOUR CODE GOES BELOW import sys import sorthelper print("Sorted list: ", sorthelper.sortNumbers(sys.argv)) ### END CODE
import sorthelper import argparse parser = argparse.ArgumentParser(description='Sort of a list of numbers') parser.add_argument('List', nargs='+', default=[], help='A List') args = parser.parse_args() if __name__ == '__main__': print(sorthelper.sortNumbers(args.List))
import sys import sorthelper l = [] for x in range(1, len(sys.argv)): l.append(sys.argv[x]) my_l = sorthelper.sortNumbers(l) print 'The sorted list is: ', my_l ### END CODE
import sys import sorthelper x = [] #print "Number of arguments:", len(sys.argv), 'arguments' #print "Argument List: ", str(sys.argv) argCount = len(sys.argv) #print argCount for i in range(argCount): if i > 0: x.append(int(sys.argv[i])) sorthelper.sortNumbers(*x)
import sys import argparse import sorthelper parser = argparse.ArgumentParser(description='Sort integers.') parser.add_argument('integers', metavar='N', type=int, nargs='+', help='Sorting.') args = parser.parse_args() print(sorthelper.sortNumbers(args.integers))
import sys from sorthelper import sortNumbers if __name__ == "__main__": l1 = [] total = len(sys.argv) if total < 2: print "Please enter at least 1 argument. Try again!" # Make sure there is at least 1 parameter else: for i in range(1, total): try: l1.append(int(sys.argv[i])) # Form a List except: print "You must use Integer. Please try again!" # If input is not an Integer, then exit exit() print "Your input is: ", l1 print "Your output is: ", sortNumbers(l1)