Python doesn't need to explicity declare variables in the same way languages like C/C++, Java, etc. do. By writing for comment in inComment:
you are creating a new variable called 'comment' that is set to the value of the current index of 'inComment' as it iterates through the indices for it. The thing is, with lists and tuples in Python, they don't need to be declared as only having one datatype; a list in Python can contain a string on one index, then a number, then a class instance, another list, etc. The contents of a list or tuple are fully flexible in that they can be completely of mixed data types. That being said, that means that 'comment' for the for loop will be a copy of each index, including whatever datatype that index may happen to be. Sorry for the mildly confusing explanation!
Also, the %d is an example of string formatting, the same as they have in C/C++ (is it in Java too?). Regardless, Python does not cast types for you automatically, meaning that print "comment found at line " + i
will not work because you are joining a string with an integer. You could use print "comment found at line " + str(i)
which converts 'i' to a string, which you can append to the rest of that line because its also a string. The %d is just the way for formatting a number via string formatting similar to printf in C. Here's a …