0
If all stament not working
Whats wrong with this code it raises syntacs eror if all (if not b.count(i) <2 for i in c) print ("Unique") break
8 Respuestas
+ 1
break should only be used inside loops...
anyway, what are b and c?
I guess that they are iterables defined before in your code?
0
also you must put colon (:) at end of 'if' line...
0
even after adding the colon still not working the problem is syntax error
0
have you also removed the 'break'?
0
Would the break stop it from raising the syntax error
It also says the first line is cousing the error.
0
oh, excuse me... you don't need the 'if' inside the all parenthesis:
if all(not b.count(i) < 2 for i in c):
print("Unique")
however not sure that your logic is right...
you might also wrap condition inside parenthesis:
if all(not (b.count(i) < 2) for i in c):
print("Unique")
to make obvious what to apply 'not'... or simply do:
if all(b.count(i) < 2 == False for i in c):
print("Unique")
0
You right i didnt check if my logic is write i wanted to know how to use the if all statement .
I will fix the logical problems that i have .
At the end you have been of a great help so THANK YOU VERY MUCH and have a nice day .
0
You can also simplify the condition to
if all(b.count(i) >= 2 for i in c):