I am not sure why I am getting an error when I try to run my lab

*** I’m not sure why I’m getting an error when I try to run this example ***

No such file: main.py
repl process died unexpectedly: exit status 2

Giving up. You can try again by clicking Run. You may need to fix the [interpreter] definition in the .replit file first.

Sorry for the simplicity of this problem, it’s just I’m just learning how to use replit.

Screenshots, links, or other helpful context:

"""A Regex version of the Strip Function."""

import re


def strip(text, remove=''):
    """Perform string.strip-like functions but using regexes."""
    # Removes whitespace from either end of the string
    if remove == '':
        space_regex = re.compile(r'^(\s*)(\S*)(\s)*$')
        trimmed = space_regex.search(text)
        return trimmed.group(2)

    # Removes character inputted as 2nd argument from ends of string
    else:
        remove_start = re.compile(r'^([%s]+)' % remove)
        remove_end = re.compile(r'([%s]+)$' % remove)
        start = remove_start.search(text)
        end = remove_end.search(text)
        # Allows function to strip even if only one side has remove characters
        try:
            return text[len(start.group()):len(text) - len(end.group())]
        except AttributeError:
            error_avoid = remove + text + remove
            return strip(error_avoid, remove)


# Get function arguments from user then print stripped string
user_text = input('Enter the text you would like stripped here: ')
user_remove = input('Enter the character you want stripped here'
                    ' (Removes Space as Default): ')

print(strip(user_text, user_remove))

its trying to find main.py file which it cant load the file cuz its not present

3 Likes

Welcome to Ask! Replit only runs main.py and you have no main.py so that’s your problem.
Either rename your file to main.py or follow the steps below:

Just click the next to “Files” then click “Show hidden files”. Next click on the .replit file and finally you can change the entrypoint to whatever file you want to run.

Images

Dots

Show hidden files

edited

You should also see the docs on how to configure a Repl: https://docs.replit.com/programming-ide/configuring-repl

And if you want to run the last edited file, take a look at this post:

3 Likes

Thanks, I also didn’t realize that I didn’t define ‘pattern’. I also can’t see very well right now. I just went to the eye doctor a couple of days ago and my prescription has gone up in strength by 5! It has been 4 years since I went to see the eye doctor. :nerd_face: :astonished:

… Sorry , that last comment about ‘pattern’ was for another problem. Darn eyes and blurry vision.