Originally Posted by Mehwish-S
I am guessing that you meant, "now
If you have some part of the program working and it doesn't give the output you expect, then one approach to debugging involves putting print statements at strategic points in the program.
When you read a line, print the line.
When you split a string, print all of the resulting strings.
Stuff like that.
Now, if you get to a point where you simply don't understand the way it works (or doesn't work), then here are my suggestions:
- Post a small input file (a couple of lines will be enough to show us the format).
- Post your code that shows where you put the print statements.
- Post the program output. (Paste the output into your post. Don't just tell us that you "got the wrong answer." Show us.)
- Tell us what you expected to happen.
- Tell us what, exactly, you don't understand about the difference between what you expected and what you got.