My code is not giving output

Question:
Why my code is not giving output? when I tap on run, the output console shows up blank
Repl link: https://replit.com/@qkytkk9qd2/Python#totp.py

import pyotp

totp = pyotp.TOTP("WCCWGCWLZGG74UK6DLKSRPSDDQMLHVS2")
totp_pin = str(totp.now())
print(totp_pin)

On default, Replit only runs the main.py file so you will need to find a way to execute the code in the file. Wrapping it in a function should work.

Thanks for the info @jcarlsontcsp,

Could you please help me knowing how to run different python files ?

To run functions in other python files, you can import the files in main.py and then call your function.

Example

# Import the File
import totp_main

# Run a function
totp_main.testFunction()

You can actually change what file is run, in the .replit file, change these lines (where it says main.py, change it to whatever file you want to run when the run button is clicked):

run = "python3 main.py"
entrypoint = "main.py"

I tried, its not working.
When I tap on run, the output console shows up blank again.

My file is TOTP_main.py
I tried like this below –

run = “python3 main.py”
entrypoint = “TOTP_main.py”

run = “python3 TOTP_main.py”
entrypoint = “TOTP_main.py”

run = “python3 TOTP_main.py”
entrypoint = “main.py”

None of them did worked.

Your file seems to be named in lowercase:

run = "python3 toptp_main.py"
entrypoint = "toptp_main.py"

But also, you’ve added that code in main.py, not .replit.
show hidden files
.replit file
But you don’t have to do any of this if you were just going to use the main.py file and import the parts you want to run in main like @jcarlsontcsp suggested.

Thank you so much @MattDESTROYER for the info. It worked.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.