I am 100% new to python, I know I need to read more but I need to do this task right now that's why I am using python for it. Here is my code:
outputList = []
for line in open('cron.log', 'r'):
m = line[45:47]
outputList.append(m)
So I opened the file, read through lines, and append the 2 chars I need into a list. Now I want to go from the end (or beginning of the list), comparing the element at that position with the element right before (or behind) it. How can I do that? In C++ I would be doing iterrator, using front(), pop_front() or such but I am clueless about python :(
outputList = [line[45:47] for line in open('cron.log', 'r')]As for your comparison, I don't yet understand what you are trying to accomplish. Perhaps you could add an example of the desired output?read the file cron.log for me line by line and chop out characters 46, 47 from those lines and store them in a list. After this I think you should only learn python if you have strong understanding about one of the other High Level Language (C++, Java, or even C) so that you know what the hell is going on behind the scene.