So as a noob in python I was working on using sets and swapping values. I was using an "if" statement for swapping the values however, it doesn't give me the results I want. Here is a snippet:
group = set([a,b,c,d,e,f])
def k():
if "W"*1 or "W"*2 in group:
print("there are 1 or 2 W")
if "W"*3 or "W"*4 in group:
print("there are 3 or 4 W")
Now the problem here is that the code above the set gives the letters in the set a value of either W or L. After this I want it to check how many of the W are present in the set and print accordingly however, if there are 3 or 4 Ws it prints both "there are 1 or 2 W" and "there are 3 or 4 W". I know why this problem occurs, but as a noob in python I don't know what else to do.
Aucun commentaire:
Enregistrer un commentaire