You have 2 problems.
After adding a line to the screen using addstr, you do not specify it to refresh the screen. Add this after calling addstr:
screen.refresh()
You need to call endwin () at the end of your program to reset the terminal. Add this to the end of your program:
curses.endwin()
However, after making these two changes at the start of your program, this will do nothing, because after displaying the lines on the screen, the curses end and return the screen to the state before the program starts.
Add this before calling endwin ():
screen.getch()
Then it will wait for the key to be pressed until it exits.
Craig source share