listdir

Chris Angelico rosuav at gmail.com
Mon Sep 5 11:39:27 EDT 2016


On Tue, Sep 6, 2016 at 1:27 AM, Smith <smith at smith.com> wrote:
> Hello to all,
> I wanted to know because even though the files are present on the directory
> I write input gives me "file not found".
> You can help me?
> Thank you
>
> a = input("Digita la directory dove vuoi trovare i file py:  ")
> for file in os.listdir(a):
>     if file.endswith(".py"):
>         print(file)
>     else:
>         break
> print("File not found")

What exactly are you expecting the 'break' to do here? Can you explain
to me the intent of your code?

ChrisA



More information about the Python-list mailing list