Read() function doubt

Hi,
I am trying to use :
f=open(“my.txt”)
print(f.read(2)) // to print first 2 character
But it is not printing anything, just skipping
What to do? I am using IDLE

Hello @vatsal50, pls try mentioning the mode while opening the file whether read mode or writing mode. And also try to run it on your terminal if it works or not.
Also, make sure my.txt file is there in the same folder where you are writing the commands.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.