Ask coding questions

← Back to all posts
Only Main file runs
mishram1271 (0)

When I add any file on my repl, it does not run. only the main file runs. Please can any one help on this

Commentshotnewtop
ash15khng (393)

repl.it only runs the main file when you run the code.
What language are you using? If you are using Python, you can import your code in the main file by using import filename where filename is the filename without the .py extension. For other languages, I can't really help.

heyitsmarcus (287)

Can you post your repl link please?

mishram1271 (0)

@heyitsmarcus https://repl.it/@mishram1271/PLAB-R4Task2
Here I made a new file Task3.py.
If tried to run it, the main file will run instead of the Task3.py

heyitsmarcus (287)

@mishram1271 As @ash15khng said, you have to use import <filename> where <filename> in this case is Task3.

So, if you wanted Hello World to print at the beginning, your code in the main file would be:

import Task3

st = "1GOAL9"
l = len(st)
st1 = ""
for i in range(0,l):
  e = st[i]
  if (e >='a' and e<='z'):
    st1 = st1 + e
  if (e >='A' and e<='Z'):
    st1 = st1 + e + e
  if (e >='0' and e<='9'):
    st1 = st1 + "#"
print(st1)
heyitsmarcus (287)

@mishram1271 You're very welcome. Happy Coding! =]