I am doing a small program to help me with learning Python (which I am very new to). I'm using Python 3.2.
In the Python shell, when I enter
f = open('filename.txt', 'r') f.readlines() it prints everything in the filename.txt. However, when I type it in a new window and save it with the .py extension, it does not show any output when I run it. It also does not give me any errors.
The code looks somewhat like this:
f = open('filename.txt', 'r') f.readlines() while True: f = open('filename.txt', 'a') inp = input('Enter text: ') rest of code... How do I print everything in the file before going through any of the while statement?
print()function? Or are you just hoping that it will display something. The>>>prompt (interactive Python) is special because it magically prints things. Are you hoping for this in a script? Is that what your question is?