You can detect a key press and if that char is G 7 or N you can add a new line "\n"
You can check out this thread to see how you can detect keypresses.
Polling the keyboard (detect a keypress) in python
check out the bottom answer, it includes a package for easily detecting presses
Update
You will ned to use some keypress detection or something instead of while loop to do this "on the fly", but I think this will get you started;
(though this is working, while() is only there to show where onpress or what you come up with should be, can be removed and script works fine)
import sys
#you need to change while() with on_press from a click listener or something
while(True):
bytes = sys.stdin.read() #reads "string"
size_of_stdin = len(bytes) #reads string length
if size_of_stdin > 7: ## size greater than 7 print;
print "You won!!" # prints
print "\n\n" # newlines
Reason you need to detect keypresses is that you have to "execute" the script manually now.
As in enter some text
1234567 (press enter)
then ctrl+z and enter again. (just to make it harder :p)
Then it looks like this in your terminal
1234567
^Z
You won!!
Hope you figure it out, let me know if anything is unclear or if you don't find a way to detect presses and execute on after 7 presses.