Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 months ago.
Improve this question
Lets say I have:
for file in files
print(file)
But what I want is
for file in files
print(x)
where x is the iteration # of the current file as the program loops through all the files.
Use enumerate function
for ind, file in enumerate(files)
print(ind)
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm learning "Google colab" and got some problem with data reading. I've written a python script for filling folders names into arrays, but it doesn't fill at even one.
TEST_PATH = "/content/gdrive/'My Drive'/test/"
test_ids= []
try:
test_ids = next(os.walk(TEST_PATH))[1]
except StopIteration:
pass
list "test_ids" still empty, but there are some folders with files in TEST_PATH:
here you can check it
Change your path like this: TEST_PATH = "/content/gdrive/My Drive/test/"
And to list files, I think it should be this: next(os.walk(TEST_PATH))[2].
next(os.walk(TEST_PATH))[1] will list the folders.
You can see more details in this answer: https://stackoverflow.com/a/10989155/11524628
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
The question
I began a Python course about 3 weeks ago. Although struggling, I would like to know what I am doing wrong in line 3.
Missing : to indent the if statement -
if "LOL" in user_tweet:
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have this code, but for the line "if c=a and d=b+1:", it says SyntaxError: invalid syntax. What is wrong with it?
if c=a and d=b+1:
print("YES")
You need to use == for comparison. = is for assignment to a variable
if c==a and d==b+1:
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
Why isn't this giving an output? It is meant to take a sentence as an input and then output the identification of each word.
You never call the function. You do need to run the function to get the output:
print word_identify(words)
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
There are different files in a folder, I would like to print files which are ended with IHDRT.exr. The correct answer for this job is as shown bellow:
#!/usr/bin/env python
import glob
for file in glob.glob("*.exr"):
if file.endswith('iHDRT.exr'):
print(file)
#!/usr/bin/env python
import glob
for file in glob.glob("*.exr"):
if file.endswith('iHDRT.exr'):
^^^^^^^^
print(file)
Its endswith and not endswidth
Use endswith, not endswidth! Error spelling