For loop errors with similar condition [closed] - python

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 3 days ago.
Improve this question
s=qA2
If I run
print(any([i.isalnum() for i in s]))
I get O/P: True
but if I run
for i in (s):
print(any(i.isalpha()))
I get error:
Traceback (most recent call last):
File "/tmp/submission/20230217/12/48/hackerrank-002b9f41abed55542d588ed9721a088b/code/Solution.py", line 7, in <module>
print(any(i.isalpha()))
TypeError: 'bool' object is not iterable
Please explain why they are not the same.

Related

NameError: name 'join' is not defined [closed]

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 4 months ago.
Improve this question
I used this code:
randomstr = '',join((random.choice(chars)) for x in range(10))
It comes up with this error:
NameError: name 'join' is not defined
I expected a picture file to be saved after being uploaded.
You made a mistake putting "," , the join comes after the "."

Python/Pygame Error: IndentationError: unindent does not match any outer indentation level [closed]

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 1 year ago.
Improve this question
when i run the code, the error shows up. What can i do to repair it?
Error: [1]: https://i.stack.imgur.com/yNJAq.png
Code: [1]: https://i.stack.imgur.com/OECRS.png
(Code is not finished yet)
There is one extra space in your code where you are calling flip() method.

Attribute Error for Python Class, but is declared [closed]

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 am getting an attribute error for one of my python class, but I declared it in the init function for the class. I do not know what I am doing wrong
You spelt "__init__" wrongly as "__int__"

if statements with and or - not working [closed]

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:

Why is this not outputting anything? [closed]

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)

Categories