#sdpsgssolutions #Triple Hunting #Starter Problems 3 # Open the input and output files. inputFile = open("tripin.txt", "r") outputFile = open("tripout.txt", "w") # Read how many numbers there will be myInput = inputFile.readline() n = int(myInput) # Reads the integers integerposition = 1 tripleList = [] while integerposition <= n: myInput = inputFile.readline() a = int(myInput) if a % 3 == 0: tripleList.append('3') else: tripleList.append('0') integerposition = integerposition + 1 howManyThrees = tripleList.count('3') if howManyThrees == 0: outputFile.write('Nothing here!') else: outputFile.write(str(howManyThrees)+'\n') positions = [i+1 for i,x in enumerate(tripleList) if x == '3'] for items in positions: outputFile.write(str(items)+' ') # Finally, close the input/output files. inputFile.close() outputFile.close()