Dec-22-2018, 11:20 PM
My multiple-choice marking program gives me a csv file, which I read in python and then enter in an Excel sheet.
My code for choosing which class looks clumsy, but works. I feel there must be a more elegant way to do this. Could you give me any suggestions, please?
My code for choosing which class looks clumsy, but works. I feel there must be a more elegant way to do this. Could you give me any suggestions, please?
classNum = input() while classNum not in classses: print('Please enter 17BE1, 17BE2, 17BE3 or 17BE4.') classNum = input() pathsToExcel = ['/home/pedro/winter2018/17BE/17BEC1/', '/home/pedro/winter2018/17BE/17BEC2/', '/home/pedro/winter2018/17BE/17BEC3/', '/home/pedro/winter2018/17BE/17BEC4/'] resultFiles = ['17BE1W17results.xlsx', '17BE2W17results.xlsx', '17BE3W17results.xlsx', '17BE4W17results.xlsx'] if classNum == '17BE1': pathXL = pathsToExcel[0] if classNum == '17BE2': pathXL = pathsToExcel[1] if classNum == '17BE3': pathXL = pathsToExcel[2] if classNum == '17BE4': pathXL = pathsToExcel[3] if classNum == '17BE1': resultFile = resultFiles[0] if classNum == '17BE2': resultFile = resultFiles[1] if classNum == '17BE3': resultFile = resultFiles[2] if classNum == '17BE4': resultFile = resultFiles[3]